Computing.Net > Forums > Unix > script for deleting unix files

script for deleting unix files

Reply to Message Icon

Original Message
Name: thaj
Date: May 11, 2004 at 21:46:43 Pacific
Subject: script for deleting unix files
OS: Windows NT
CPU/Ram: 512Mhz
Comment:

Hi,
I am having files like control and big in /home/sam dir., These files are generated daily with timestamp. If both files cross more than 30 days, the latest one month files should be retained. can i use find with mtime for this?.


Report Offensive Message For Removal


Response Number 1
Name: thepubba
Date: May 12, 2004 at 06:19:50 Pacific
Subject: script for deleting unix files
Reply: (edit)

Thaj:

You still haven't provided sufficient information. File names for example to create your pair set for comparision. An example would be:

051204.in 051204.out

One could then test for age on each file and create logic that says if 051204.in AND 051204.out are greater than 30 days old THEN keep the older file.

Post a little more detail.


Report Offensive Follow Up For Removal

Response Number 2
Name: twinkleblue
Date: May 25, 2004 at 02:53:26 Pacific
Subject: script for deleting unix files
Reply: (edit)

my understanding is that you wish to remove files that are more than 30 days.

you can try this is that is the case:
find /home/sam -mtime +30 -exec rm -f {} \;

Food for ThoughT?


Report Offensive Follow Up For Removal

Response Number 3
Name: jwalshaw
Date: June 9, 2004 at 07:39:33 Pacific
Subject: script for deleting unix files
Reply: (edit)

Great feedback! This is what I was looking for also. It's important that when you write a script to do this that you don't just delete them. Figure out who created them, talk to them, also review the list and then when you are sure delete the files.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: script for deleting unix files

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge