Good time of the day,

Is there way to tell the bash "find" command to output what it is doing (verbose mode) ?

For example for the command: find /media/1Tb/videos -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \; to output:

Found /media/1Tb/videos/102, executing rm -rf /media/1Tb/videos/102

...

link|improve this question

80% accept rate
feedback

3 Answers

up vote 6 down vote accepted

You could concoct something with -printf, but the easiest is just to tack on -print on the end. This will show what was successfully deleted.

link|improve this answer
this answer can be applied to anything when using find, so thumbs up – Alex Oct 7 '11 at 8:09
feedback

How about just using rm -vf for verbose rm output.

$ touch file1 file2 file3
$ find . -name "file?" -exec rm -vf {} \;
removed `./file2'
removed `./file3'
removed `./file1'
link|improve this answer
the verbose option for rm is cool but if I replaced it with something else I can no longer see what files are being worked on (unless I use echo inside -exec) – Alex Oct 7 '11 at 8:10
feedback

An alternative is to let the commands be executed by sh -x:

$ find . -type f -print0 | xargs -0 -n1 echo rm | sh -x
+ rm ./file1
+ rm ./file2
+ rm ./file3
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.