Monday, March 14, 2011

recursively removing files with wildcard in linux

If you are a Linux rookie as me, you might expect this to work, as well as I did:
rm -r *.class

Bozinga! this only deletes the *.class under wherever you are, because wildcards are expanded before executing the commands.

here is a non-trivial command that does the seemingly trivial magic you wish:
find /path_to_search -type f -name "*the_patern*" -exec rm {} \


No comments: