I was wanting to run a find
and then execute a script on each match; however, I was wanting to print the name of the matched file above the output from each exec
. How can I produce the following output:
$ find . -name 'something' -exec sh script.sh {} \;
./something_1
output from
script.sh something_1
./something_2
output from
script.sh something_2
I am currently only getting the output from script.sh
. I tried -exec echo {} && sh script.sh {} \;
with no success.
I would prefer a solution using -exec
or xargs -print0
, i.e., not prone to problems with white space.
find -find_options | xargs script.sh
– Johan Mar 1 '13 at 5:17