deleting a list of files


Suppose you have a dirctory of thousands of files, you need to delete some of them.  If the filenames are sufficiently friendly, you can do it easily with a command line.

For example:

rm *.old or rm old*.zip

But, consider this case: files are named with the date they were  generated and there are two types of names

  1. those look like, and
  2. those look like

Is there a way to only delete the files with "mini" within the filename?

It is not hard to get the list of these files, in linux, it is simply:

ls | grep mini >listfile

Searching in google, I found a linux command called "fastrm" that does delete all files in the list "listflie", but I don’t have it in my Redhat Enterprise Server 3.

So I wrote the following script to do that:

 open (FILE, "< listfile");

while (<FILE>){
close FILE;

 Now it is very easy to delete files in the list:

 the command is : ls |grep mini>listfile; perl;

Leave a Reply

You are visitor number several since September 1, 2001

Copyright Xiaoquan (Michael) Zhang, 2004-2020. All rights reserved.
All trademarks property of their owners.