This is a recurrent issue I have always had while dealing with iterations or actions over files found using find.
I have the following files:
$ find . -name "*ES 03-11*"
./01jan/ES 03-11.txt
./02feb/ES 03-11.txt
./03mar/ES 03-11.txt
./04apr/ES 03-11.txt
./05may/ES 03-11.txt
And I would like to launch the following command:
$ cat "./01jan/ES 03-11.txt" "./02feb/ES 03-11.txt" "./03mar/ES 03-11.txt" "./04apr/ES 03-11.txt" "./05may/ES 03-11.txt" | process
Which means concatenating each line provided by find but enclosed into double quotes or simple quotes I guess.
I have tried this:
find . -name "*ES 03-11*" | awk '{printf "\"%s\" ", $0}' | xargs cat | process
Which seems to work, but I am wondering if there is any other way to do it without using awk or doing something easy to remember or type.
I am using FreeBSD and Bourne Shell.
find . -name "*ES 03-11*" -exec cat {} +
? – iruvar Dec 19 '20 at 21:51-exec utility [argument ...] {} +
section at the man page – iruvar Dec 19 '20 at 22:02