touch 1.txt 2.txt
find . -name "[12].txt" -exec sh -c 'echo "${1}"' sh {} + -exec echo {} +
./2.txt
./2.txt ./1.txt
Why echo
within sh -c
outputs only one file? Today I thought I understood how find
works from Understanding the -exec option of `find` but now puzzled again. Got same result for -exec bash
. TIA
find . -name "[12].txt" -exec cmp {} + -exec sh -c 'if [ "${1}" < "${2}" ] ; then echo "${1}" ; fi' sh {} +
even ascmp
outputs "files differ" nextexec
withecho
runs. Why? How testing with exec works? P.S. I know it might be another Q. If not answered as comment, I plan to post it. – Alex Martian Jul 27 '23 at 17:14{} +
was used only at the end, check was done with{} ;
. – Alex Martian Jul 28 '23 at 01:08