Is there a way to see what the result of a find . -exec somecommand {} \;
would be with substitutions, without actually running the commands? Like a dry run (or test run or print)?
For example, suppose I have the following file structure:
/a/1.txt
/a/2.txt
/a/b/3.txt
Is there a way to test find . type f -exec rm {} \;
from within the a
directory such that the output would printed to stdout but not executed such as:
rm 1.txt
rm 2.txt
rm b/3.txt
Update
Note: rm
is just an example command, I'm interested in the general case
-exec
may well affect the pathnames found byfind
. Thus, doing a "dry run" would potentially find different files from when running for real. Note that-exec
acts like a test, just like-name
, so if the-exec
code returns false, the next stage is not executed for this pathname.