4

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?

1 Answers1

6

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.

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497