Find the answer to your Linux question:
Results 1 to 7 of 7
Hi all, When i tried the command, Code: sudo find / -type f -name *.pdf -exec cp {} . \; Code: /usr/bin/find: paths must precede expression Usage: /usr/bin/find [-H] [-L] ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,758

    Question Problem with find command


    Hi all,
    When i tried the command,
    Code:
    sudo find / -type f -name *.pdf -exec cp {} . \;

    Code:
    /usr/bin/find: paths must precede expression
    Usage: /usr/bin/find [-H] [-L] [-P] [path...] [expression]
    it worked perfectly few hours back.
    what could be the problem? and what's this error mean?
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  2. #2
    Blackfooted Penguin daark.child's Avatar
    Join Date
    Apr 2006
    Location
    West Yorks
    Posts
    4,393
    Works fine for me using
    Code:
    find /some/path -type f -name "*.pdf" -exec cp {} . \;

  3. #3
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,758

    Post

    I looks like a issue( bug??) with find command:

    now it works when i type
    Code:
    sudo find / -type f -name *.pdf -exec cp {} . \;
    i tried to change pdf to txt - it shows the same error again.
    Code:
     sudo find / -type f -name *.txt -exec cp {} . \;
    i get the msg

    Code:
    /usr/bin/find: paths must precede expression
    Usage: /usr/bin/find [-H] [-L] [-P] [path...] [expression]
    quite strange!!!
    Did you know the meaning of above error?
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  4. #4
    Linux Enthusiast
    Join Date
    Aug 2006
    Location
    Portsmouth, UK
    Posts
    539
    Try retyping the command, I ran into this issue a few days back and it turned out to be a cut 'n' paste issue. Go figure
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

  5. #5
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    One thing that is striking me is that you are not quoting your shell patterns (*.pdf, *.txt, etc.). Because they are not quoted, they are expanded by the shell, rather than being passed in to find.

    Try quoting them and see if that helps.

  6. #6
    Linux Enthusiast
    Join Date
    Aug 2006
    Location
    Portsmouth, UK
    Posts
    539
    Well spotted Cabhan , though I don't think it's the cause of the problem (I was quoting the patterns but still had the problem, although I bet it had something todo with cutting a pasting from M$ notepad )
    RHCE #100-015-395
    Please don't PM me with questions as no reply may offend, that's what the forums are for.

  7. #7
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,758

    Smile

    Yes,Cabhan. It works when put quotes around it like
    Code:
    sudo find / -type f -name "*.pdf" -exec ls -l {} \;
    But works even without quotes.
    Code:
    sudo find / -type f -name *.jpg -exec ls -l {} \;


    Hi matonb,
    I tried to cut-n-paste i got the errors and
    typed the command at terminal - still i'm getting the errors.


    anyway using quotes solves my issue with find
    Thanks guyz.
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

Posting Permissions

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