Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show deleted file when using command `find . -name sample.txt -delete`

Tags:

find

verbose

I need the output just like rm -v sample.txt. Are there options like "-v" in command find?

like image 600
bo he Avatar asked Sep 13 '25 09:09

bo he


1 Answers

Tested with FreeBSD and Busybox implementations of find:

$ find . -name sample.txt  -delete -exec echo removed "'{}'" \; | sed "s,^removed '\./,removed ',"
removed 'sample.txt'

With GNU find you can also use -printf:

$ find . -name sample.txt -printf "removed '%f'\n" -delete
removed 'sample.txt'
like image 164
Arkadiusz Drabczyk Avatar answered Sep 15 '25 08:09

Arkadiusz Drabczyk