Advertisement

07.08.2005 at 10:52AM PDT, ID: 21485139
[x]
Attachment Details

shell script to selectively delete files based on date

Asked by daschund in Linux Programming

Tags: files, delete, script, shell, date

Hello,

I'm fairly new to Linux and although I can find my away around the basics and understand a lot of the concepts, I'm having trouble putting together a shell script to perform what seems like it should be a simple task!

I'm trying to write a shell script (that will be run as a cron job) to do the following:

tar/gzip all of the log files in a directory EXCEPT for the one with the current date (since it's still in use)

(I know the command to do this for ALL log files, but I can't figure out a way to exclude the current day's log file by its date (ctime) stamp.)

verify that the tar.gz file was successfully created

delete the individual log files that were added to the tar.gz file from the directory EXCEPT for the current day's log file

(Again, I know how to rm the files -- but, I want to rm all of them EXCEPT for the current day's log file.)

There are SO many unix/linux command switches and combinations of piped commands that it's frustrating to figure this out.

I'm sure it's a no-brainer for someone who's been using Linux for a while.

Thanks for your replies!

- dStart Free Trial
[+][-]07.08.2005 at 12:03PM PDT, ID: 14399870

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Linux Programming
Tags: files, delete, script, shell, date
Sign Up Now!
Solution Provided By: ravenpl
Participating Experts: 2
Solution Grade: B
 
 
[+][-]07.12.2005 at 03:26AM PDT, ID: 14420049

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.12.2005 at 03:27AM PDT, ID: 14420052

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.06.2005 at 10:30PM PDT, ID: 14834145

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32