I retrieve a booklist after seaching the python books in home directory using this command on OSX:

    find ~ -type f -iregex '.*python.*\.pdf'

the booklist


I intend to check their status with command xargs and stat

    $ find ~ -type f -iregex '.*python.*\.pdf' | xargs stat -x
    # get error
    xargs: unterminated quote

Tried alternatively with option -0

    find ~ -type f -iregex '.*python.*\.pdf' | xargs -0 stat -x 
    # get error
    : stat: File name too long

How to resolve such a problem?

  • this is on OSX, I assume? (stat -x) – Jeff Schaller Mar 27 '18 at 12:59
  • 1
    Note that -iregex '.*python.*\.pdf' will match on /path/to/python/whatever/foo.pdf. If you want to match on files whose name (as opposed to full path) contains python and ends in .pdf, use -iname '*python*.pdf' or -iregexp '.*python[^/]*\.pdf' – Stéphane Chazelas Mar 27 '18 at 13:33

-0 to xargs doesn't make much sense if you don't also change the input to be 0-separated. Try find ~ -type f -iregex '.*python.*\.pdf' -print0 | xargs -0 stat -x

  • 1
    Some xargs implementations also have a -r option to not run the command if the input is empty (on FreeBSD, it's implicit). – Stéphane Chazelas Mar 27 '18 at 13:35

protected by Community Jun 8 '18 at 13:30

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.