What command should I use to rm all .png files in a folder and subfolder?
6,830
You were very close:
find -type f -iname '*.png' -exec rm {} \;
As edwinksl pointed out, using -delete
flag also works:
find -type f -iname '*.png' -delete
In bash
shell alone we can do
shopt -s globstar
rm ./**/*.png
This, however, might suffer from Arguments list too long
error, if number of files expanded is large, or environment passed to the command is also large. As always, remember to append echo rm ./**/*.png
to see what will actually run.
Related videos on Youtube
Author by
user285884
Updated on September 18, 2022Comments
-
user285884 over 1 year
I started with this based off of another question I had:
find -type f -iname '*.png' -exec rm
that clearly didn't work, but am I atleast warm?
-
edwinksl over 7 yearsYou could replace the
-exec rm
part with-delete
.
-