Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

...

share|improve this question

3 Answers

up vote 11 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.

share|improve this answer
this answer can be applied to anything when using find, so thumbs up – Alex Oct 7 '11 at 8:09
my find love grew another just another little bit. thanks :) – Darragh Jun 14 '12 at 22:59
For me, using "-exec rm -vf {} \;" worked better. – djangofan Oct 24 '12 at 20:50

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'
share|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

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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