Find the answer to your Linux question:
Results 1 to 2 of 2
First of all, was not sure if this was the right section because there are so many but hey it's a newbie question so this seemed right. Now for my ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2011
    Posts
    1

    Need help with a command that I can't seem to get a hold off


    First of all, was not sure if this was the right section because there are so many but hey it's a newbie question so this seemed right.

    Now for my question:

    So what I need is:
    I need to search the /etc directory for anything with "passwd" in it. From those results I want the first 2 lines of what was in the found files.
    Then it needs to go to the file /root/papier

    What I thought would work:
    Find /etc –name “*passwd*” –exec head {2} > /root/papier

    But for some reason it gives this error: find: missing argument to -exec
    I don't get it what needs to go with exec, looked at manpages but still can't figure it out

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,633
    Quote Originally Posted by zotox View Post
    First of all, was not sure if this was the right section because there are so many but hey it's a newbie question so this seemed right.

    Now for my question:

    So what I need is:
    I need to search the /etc directory for anything with "passwd" in it. From those results I want the first 2 lines of what was in the found files.
    Then it needs to go to the file /root/papier

    What I thought would work:
    Find /etc –name “*passwd*” –exec head {2} > /root/papier

    But for some reason it gives this error: find: missing argument to -exec
    I don't get it what needs to go with exec, looked at manpages but still can't figure it out
    Try this:
    Code:
    find /etc -name '*passwd*' -exec head --lines 2 {} > /root/papier \;
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •