Find the answer to your Linux question:
Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By atreyu
Hello, I need to use the find command to find files owned by a specific user, and direct/copy them to another directory. This is the syntax that I have used ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Dec 2009
    Posts
    106

    Using the find command


    Hello,

    I need to use the find command to find files owned by a specific user, and direct/copy them to another directory. This is the syntax that I have used :
    Code:
    find / -user harry -type f -exec cp {}/root/harryfiles\;
    The destination directory is /root/harryfiles. However when I execute the command above, I get an error :

    Missing argument to exec

    What is the correct command? Please help.

    Thanks,

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Quote Originally Posted by anaigini45 View Post
    Code:
    find / -user harry -type f -exec cp {}/root/harryfiles\;
    hi,

    try adding spaces after the "{}" variable, and before the "\;", which signifies the end of the "-exec" statement, e.g.:
    Code:
    find / -user harry -type f -exec cp {}  /root/harryfiles  \;
    Lakshmipathi likes this.

  3. #3
    Linux Newbie user-f11's Avatar
    Join Date
    Feb 2011
    Location
    Sofia, BG
    Posts
    185
    RE: 'what is the correct command'
    $ find --help
    Copy with mouse left-click and drag, then right-click and copy the text from the terminal, and after that paste it into some text file ... and print it on paper (to have it at hand).

  4. $spacer_open
    $spacer_close

Posting Permissions

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