Aid with a find command

I have a number of directory sites. Inside these directory sites is a cover letter and also a zip archive of job. I intended to run a fast and also very easy question to open all the cover letters so I can determine if it's worth considering the job folder.

find . | grep cover\.pdf | xargs open    #OS X has open linked to "open" the file

This does not function. I've additionally muddied around with numerous print0, xargs -0 variants with little success. What's the correct means to do this?

2019-05-06 01:42:15
Source Share
Answers: 3

This needs to function :

find . -name cover\.pdf -exec open '{}' \;

You can examine similar to this :

find . -name cover\.pdf -exec ls -l '{}' \;

Not exactly sure what the male web page resembles on OSX, yet there are numerous instances in the find male web page, if you look for EXAMPLES. I usually find myself revitalizing my mind by examining those.

2019-05-08 10:52:47

If your xargs on your system sustains - n alternative you can attempt adhering to.

find . | grep cover\.pdf | xargs -n 1 open

2019-05-08 10:45:23

First, constantly examine what variations of find/ xargs you in fact make use of on your Mac - OSX box. Probably you anticipate BSD/GNU behavior/options and also make use of GNU/BSD variations.

Do not recognize if open assistances numerous debates. Otherwise call xargs similar to this :

xargs -n 1 open

(which suggests that xargs implements for every single argument an added open procedure)

And remember that find | xargs without -print0/-0 is anticipated to fall short if your filenames/paths have rooms.

Aha, if you make use of something like

find -print0 | grep something | xargs -0 foo

after that grep is perplexed by all the \0 personalities.

GNU grep (at the very least) recognizes the -z alternative. Hence, which need to function is :

find -print0 | grep -z something | xargs -0 foo

Examine what grep variation you make use of using

grep --version

Or examine the male web page of your grep for \0 (absolutely no personality) assistance.

2019-05-08 09:34:23