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.
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
- those look like file20051002.zip, and
- those look like filemini20051002.zip
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");
Now it is very easy to delete files in the list:
the command is : ls |grep mini>listfile; perl rmlist.pl;