Friday, December 3, 2010

Recursively Deleting Files in UbuntuLinux

Neat way to recursively delete files in directory specified from command line....

find /media/data/Images -name \*.gif -exec rm {} \;

Source: Adapted from TechRecipes
In the example above, I'm deleting GIF image files from the Images directory. Saves me the trouble of clicking my way through a few zillion folders.

Careful with this command...switch to the parent directory where you have all the empty directories, and then execute the following to remove all empty directories.
find -depth -type d -empty -exec rmdir {} \;

Delicious Bookmark this on Delicious
Subscribe to Around the

Everything posted on Miguel Guhlin's blogs/wikis are his personal opinion and do not necessarily represent the views of his employer(s) or its clients. Read Full Disclosure

No comments:

The Courage to Lead