Find -exec Dry Run?

execfind

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

Best Answer

You can run echo rm instead of rm

find . type f -exec echo rm {} \;

Also, find has -delete option to delete files it finds

Related Question