Azitech

Azimout's Linux weblog

Delete a long list of files

leave a comment »

Say you wanna search your filesystem for files matching certain criteria and remove them. Here’s how to do it:

Create a text file containing the list of files you want to remove, e.g. like this:

locate abcd | /bin/grep /usr/local > filelist.txt

Inspect filelist.txt carefully to make sure you’re not removing anything you want to keep. Then remove those files like this:

for i in `cat filelist.txt`; do sudo rm -r $i; done
About these ads

Written by azimout

31/10/2011 at 15:17

Posted in Howto

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: