There are several ways that you can do this with "find", and it doesn't have to be based on name, it can be by file type, date, etc:
- Code: Select all
$ find /somebasedir/somestartingsubdir -name '*.bak' -exec rm -f {} \;
would delete all *.bak files anywhere under /somebasedir/somestartingsubdir. Or you could do it this way:
- Code: Select all
$ find /somebasedir/somestartingsubdir -name '*.bak' | xargs rm -f
Those are probably the easiest ways. If you wanted to just run the command first without deleting files so you can make sure it will only delete the files you want then run it withou the "-exec ... ..." or without the "|xargs rm -f" then add the rm command on the end when you get the search list the way you want it. The find comand is extremely powerful and useful. It would be good to just brush through the man page:
http://voidmain.is-a-geek.net/man/?parm ... ocType=man