How can i remove the files generated on 10 days before!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can i remove the files generated on 10 days before!!!
# 1  
Old 11-17-2009
How can i remove the files generated on 10 days before!!!

Dear Friends!

i am wirking on the IBM AIX version 5.3. and i wrote a script to delete the files whicha re generated on 10 days before to the present day. but iam not able to delete the files with the below script so please check and correct me.

[code]
dt=`TZ=aaa480 date +%d`
mt=`TZ=aaa480 date +%b`
rm -f `ls -ll | awk '$7 == '$dt' && $6 == '$mt''| awk '{print $9}'`
[code]

files in the directory are displayed as below.
[example]
-rw-r----- 1 smp tellin 1492 Nov 17 10:06 sms_oplog_smpsys_1266_20091117.log
-rw-r----- 1 smp tellin 1752 Nov 17 11:24 sms_oplog_smpmml_internal_20091117.log
[Example]
# 2  
Old 11-17-2009
with find you should be able to do it, very simply.

1. List files which are modified in the before 10 days.
Code:
find . -mtime +10


2. Remove files which are modified in the before 10 days.
Code:
find . -mtime +10 -exec rm {} \;

Note: it will remove the files.
# 3  
Old 11-17-2009
Thanks friend! It is working fine...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shellscript command to remove files starting with a certain string, and older than 3 days

Hi All, Need help in identifying a shellscript command to remove all files on a server directory, starting with a certain prefix and also older than 3 days. That means files created with that prefix, today or yesterday, shouldn't be removed. Thanks, Dev (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

2. UNIX for Dummies Questions & Answers

Remove files from tar archive which are more than 1000 days old.

I am not able to extract/remove files older than 1000 days from a tar archive in linux system. #!/usr/bin/perl @file_list = `find /home/x/tmp/ -name *xxMsg* -ctime +7`; $file_name = '/home/x/tmp/new_archive.tar'; for... (1 Reply)
Discussion started by: DannyV
1 Replies

3. Shell Programming and Scripting

Remove files older than 2 days.

Hi All, I am new to the scripting and using solaris 10 OS. Please suggest me from the below script which modifications need to be done to delete the files more that 2days older. Current script is deleting existing file. # Remove old explorer runs if needed DIR=`dirname ${EXP_TARGET}` if ... (2 Replies)
Discussion started by: Navkreddy
2 Replies

4. Shell Programming and Scripting

Remove white spaces from flat file generated from Oracle table...

I have to export data from table into flat file with | delimited. In the ksh file, I am adding below to do this activity. $DBSTRING contains the sqlplus command and $SQL_STRING contains the SQL query. File is created properly with the data as per SQL command. I am getting white spaces in the... (1 Reply)
Discussion started by: mgpatil31
1 Replies

5. Shell Programming and Scripting

[Validate] Script to remove files olderthan X days

Hi, I have written a small shell script to remove the files olderthan X days (say 30). But I not sure how it acts on the filesystem, as I am using rm. if then echo "##############################################" echo "Invalid no .of arguments\n" echo "Usage:\n$0 PATH... (6 Replies)
Discussion started by: karumudi7
6 Replies

6. Shell Programming and Scripting

script to remove files older than 60 days

Hi I need help in the script which looks at a contorl file which has a list of file names like xxxx.12345 and I want to take only xxxxx and search in a specific directory and remove the file if its older than 60 days I have written something like this.. but seems to be wrong... (1 Reply)
Discussion started by: antointoronto
1 Replies

7. Shell Programming and Scripting

How to tar, compress and remove files older than two days

Hi, I'm Eddy from Belgium and I've the following problem. I try to write a ksh script in AIX to tar, compress and remove the original *.wav files from the directory belgacom_sf_messages older than two days with the following commands. The problem is that I do not find a good combination... (4 Replies)
Discussion started by: edr
4 Replies

8. Shell Programming and Scripting

Remove files which created date before 10 days on HP-UX

Hi All, Could you please let me know if there is any one can help to create a shell script to remove some files which is the created date for them greate than 10 days (sysdate-10) Please try to email me on email removed Thanks in advance, Murad (1 Reply)
Discussion started by: murad_fayez
1 Replies

9. Shell Programming and Scripting

Need to remove files older than 30 days except directories

Hi, I need to remove files (*.trc) which are older than 30 days from one location. My problem is there I do not want to visit any of the directories at that location. I want to search files at that particular location only (need to skip directorys at that location). maxdepth option is there... (6 Replies)
Discussion started by: malaymaru
6 Replies

10. UNIX for Dummies Questions & Answers

Find files older than 5 days and remove tem after listing

need help with this ... Find files older than 5 days and remove tem after listing list "test" file older than 5 days and then remove them (1 Reply)
Discussion started by: ypatel6871
1 Replies
Login or Register to Ask a Question