Datascrubing
July 16, 2004 8:37 AM Subscribe
datascrubbing: I'm using rm -R */*.gif (for example) to get rid of unnecessary files in a directory. There is stuff that's nested about five directories deep that I can't get to using the above command. I'm using the Bash terminal in OS X. specifically, there is a redundant file called "popup" nested in there that I want to get rid of, among others.
Second related problem: is there a way to recursively delete (full) directories, say ones that end in .blob using wildcards? And would I use rmdir or rm -R to do this?
I'm working on a copy of the original, so its ok to experiment a little
posted by mecran01 to computers & internet (18 answers total)
Check out the 'find' command: it's made for stuff like this. Unfortunately, the syntax is pretty rough; and of course recursively deleting things is *very* risky, even for seasoned Unix pros.
For your first question, this command should do the trick (when executed from within the directory you want to start):
find . -name '*.gif' -exec rm {} \;
If you want it to be safer, but tedious:
find . -name '*.gif' -exec rm -i {} \;
For your second question, this should work (again, navigate to the directory from which you want to begin):
find . -type d -name '*.blob' -exec rm -r {} \;
posted by Eamon at 8:42 AM on July 16, 2004