rm files older than ...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers rm files older than ...
# 1  
Old 02-06-2006
rm files older than ...

Hello,
How can I remove files older than yesterday or the day before or a given day ...
Thank you in advance
# 2  
Old 02-06-2006
To delete the files older than
find /path/to/dir -type f -mtime +3 -exec rm \{\} \


To locate files that have been modified since some arbitrary date use this little trick:

touch -d "13 may 2001 17:54:19" date_marker
find . -newer date_marker
To find files created before that date, use the cnewer and negation conditions:

find . \! -cnewer date_marker
To find a file which was modified yesterday, but less than 24 hours ago:

find . -daystart -atime 1 -maxdepth
The -daystart argument means the day starts at the actual beginning of the day, not 24 hours ago.

Narsing
# 3  
Old 02-08-2006
Thank you for your advice. That's OK for me
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 Replies

2. Shell Programming and Scripting

Archiving older files

Hello Group, I would request your help to build a shell script in order to find files older than 90 days then create the same directory structure under the second disk (/archive directory) and move the file preserving the same timestamps (ownership, etc). Also keep the log of files moved... (4 Replies)
Discussion started by: csierra
4 Replies

3. Shell Programming and Scripting

how to delete the older files other than the recently added 5 files

Number of files will get created in a folder automatically daily.. so i hav to delete the older files other than the recently added 5 files.. Could u help me through this..?? (5 Replies)
Discussion started by: shaal89
5 Replies

4. UNIX for Advanced & Expert Users

files older than 10 minutes

Hi, I have to find the files older than 10 minutes and remove those files as well as redirect the file names into a log file. i am using sun OS and my unix is not GNU and also not having perl. Could any one suggest me the way to approach. It would be great if script is provided. Also... (8 Replies)
Discussion started by: rohan10k
8 Replies

5. Shell Programming and Scripting

files older than a certain time

I know how to find files, which are newer than a specific time. touch -t 201103300650 dummy find /path/to/files -type f -newer dummy -exec ls -l {} \; Is there a way to find files, which are older than a specific time? (2 Replies)
Discussion started by: BeefStu
2 Replies

6. Shell Programming and Scripting

files older than few hours

Hi All I need to know the command which can be used to list the files which are 3 hours old so that it can be deleted. (3 Replies)
Discussion started by: mskalyani9
3 Replies

7. Shell Programming and Scripting

rm files older then 2 seconds?

Hello, I've got a script to delete 0 byte files, but I need it to work only for files that have been created at least 2 seconds ago (Are two seconds old). I'm not sure what's the best way of doing this, I've had a look at the stat command too but well.. for file in `ls -l | grep ^- |... (7 Replies)
Discussion started by: TehOne
7 Replies

8. Shell Programming and Scripting

ftp only older files

Hi All, I want to get those the files which were created before 20 days. Say, we have two server, remote server and local server. I want to get only 20 days older files from remote server to my local server. I have used following code for ftp: (echo " user ${USERNAME}... (2 Replies)
Discussion started by: priyankak
2 Replies

9. UNIX for Dummies Questions & Answers

Remove the older files

Hi All, I need to remove some old files which the file creation date is older than a week. I've tried to use command: find . -atime +6 -exec rm{}. but it seems the creation date of files shown above were not as I expected. please your kind advice. Thanks. (1 Reply)
Discussion started by: Prasandha
1 Replies

10. Shell Programming and Scripting

files older than 15 minutes

Hi Friends, i have to write a script to raise a flag if there are any files that are older than 15 minutes in the directory.The directory is supplied as the parameter to the script. please help with a sample script. Thanks in advance veera (0 Replies)
Discussion started by: sveera
0 Replies
Login or Register to Ask a Question