remove some files on a condition..

Hi.. when I do a ls -lt, I get a listing of about 200 files.. These are trace files and some of it I might not need..

To be clear, say in a given week , I might not need files that have been traced between 11 and 11:30 am on a particular day. How can I delete based on this condition ?

Thanks, ST2000

I'm in no real condition to help, but I'll try to give my $.02 anyways..

I've seen guys take your situation and pipe it into a grep 11 or 11:30 just to see the other 11 to 11:30 files. You can delete them manually for now, until someone can help you devise a script that will account for that as well.

ls -lt | grep 11

ls -lt | grep 11:30

I have gone a little more further..

ls -lt | grep "Aug 26" | grep 11:14

gives me about 10 files.. I simply want to be able to delete those ten files.. How would I do that.. Since no one has responded I shall do it manually few times..

Thanks ST2000

Realize scripting is just putting into a file what you would do manually (but adding the 'thinking' part - the logic to delete only those files - is the hard part).

You could take your command and put it in a script to collect the file names, and then loop through them and delete. You would have to pull out the last piece of the ls -lt (after confirming it to be in the range you want to delete) and delete it.

You also have to watch out that the file you are going to delete isn't a directory, that you set yourself into the correct directory...

Your first step, finding your files is coverend in your command:
ls -lt | grep "Aug 26" | grep 11:14

Put that into an awk statement to print the last portion of the string (the filename), check that it is a text file (or whatever) and not a directory, special, link, ... file, then delete it.

As far as selecting the files to delete:
Hint: Check the man pages for the find command...