I'm new to Bash. From the Finding Files documentation:
You want to find every file in ~/mydir and all its subdirectories, recursively, with a file extension of .htm (or .HTM or .Htm...) and delete it. I've seen a lot of attempts like rm -rf ~/mydir/*.htm which really don't come close. The correct solution is
find ~/mydir -iname '*.htm' -exec rm {} \;
-iname
says that you want to do a case-insensitive search on the filename.'*.htm'
is in single quotes to prevent bash from expanding the *, which will produce unexpected results.
Question: What does asterisk produce with and without the quotes? Why would you decide to use quotes versus not?
find ~/mydir -iname -type f "*.htm" -delete
, since Ubuntu uses gnu-find, which has the handy -delete switch. Simpler for typing, and find will, if you omit the -type f restriction, start a deep-first-search, and eventually delete empty directories, too.