Find command to delete the files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find command to delete the files
# 1  
Old 11-11-2013
Find command to delete the files

Hi All,
I've created 2 files
Code:
touch -t 201309101234 aa10
touch -t 201309111234 aa11

Exact 60 days before from today date is SEPT 12th . As per the following command as i gave +60 means the files which were created before sept12th should be deleted
Code:
find /etc/logs/*aa* -type f -atime +60 -exec rm -f {} \;

But the above command is deleting only aa10 file and not the aa11 file ..
Could you please help me in this .
# 2  
Old 11-11-2013
It works fine for me.

Is your system date correct?

What is the output of ls -lu /etc/logs/*aa*?
# 3  
Old 11-11-2013
Thanks for the reply scott

Code:
$ ls -lu *aa*
-rw-r--r--   1 techno tst            0 Sep 10 12:34 aa11
-rw-r--r--   1 techno tst            0 Sep 11 12:34 aa12


Thanks,
# 4  
Old 11-11-2013
At the time you issue the command aa11 was exactly 60 instead of more than 60 since last time accessed.

Code:
find /etc/logs/*aa* -type f -atime 60 -exec ls -l {} \;

# 5  
Old 11-11-2013
Thank you for reply aia

Today I executed the command . So I have given. +60means ., delete the data before Sept 12th .
but with the command I've given .. it is ins ble to delete aa11.
Please suggest.
# 6  
Old 11-11-2013
Since you did not post your last given command I am going to guess and recommend that you tested first with:

Code:
find /etc/logs/*aa* -type f -atime +59 -exec ls -l {} \;

That should pick the files up that you have been using as example and list it for you. If it does then you can substitute the -exec ls -l for -exec rm -f.
This User Gave Thanks to Aia For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find modify and delete files

hi every one. one of my friends has writen this script and send it to me. this script can find files that add-delete-modify and also send an alert by email i'm not catch all part of it. can anyone explain me how this work #!/bin/bash START="a.txt" END="b.txt" DIFF="c.txt" mv ${START}... (4 Replies)
Discussion started by: nimafire
4 Replies

2. UNIX for Dummies Questions & Answers

Find command to delete old files

Hi, I want to delete all the log files that was created on year 2008. My command is not working. Any idea? find . -name '*.log' -mtime 1460 -exec ls -lt {} \; Thank you. (2 Replies)
Discussion started by: samnyc
2 Replies

3. Shell Programming and Scripting

Find command to search and delete files older than 1 days at a desired location

Hello All, Can someone please help me out in creating the find command to search and delete files older than 1 days at a desired location. Thanks in advance for your help. (3 Replies)
Discussion started by: Pandee
3 Replies

4. UNIX for Dummies Questions & Answers

Script to find the files and delete them

This is a real world problem so I think you might found this interesting. We have servers which are shared by multiple team members. Each team member has its own user id and home directory. Now with time each user starts creating files which in end caused the disk to be full. Now for creating a... (5 Replies)
Discussion started by: Rohit06
5 Replies

5. Shell Programming and Scripting

Find command to delete a pattern

Hi all i have a directory where it has files as shown below.Using find command how can i delete files which were modified more than 20 days ago and having the pattern jnhld15231 or jnhld15232. find ./ -name "jnhld15231^" -type f -mtime +20 -exec rm {} \; find ./ -name "jnhld15232^" -type f... (2 Replies)
Discussion started by: morbid_angel
2 Replies

6. Shell Programming and Scripting

find files for a particular date and delete

How can I delete files for a particular date ? I apologize in advance If there is solution please put the link. Thanks, (5 Replies)
Discussion started by: jville
5 Replies

7. UNIX for Dummies Questions & Answers

find and delete files

hi all , i want to find and interactively delete all the files having size greater than 20 bytes using "find" and other commands..... (8 Replies)
Discussion started by: sonu_pal
8 Replies

8. Solaris

Could not able to delete the files through find command need expert advice

Hi Gurus I am facing a problem, there is a folder called /a where there are lots of files which are occupying space anything between 30 GB to 100 GB as I am not able to check the space occupied by that folder through "du -sh /a" command as I don't see any output after more than 1 hour of... (4 Replies)
Discussion started by: amity
4 Replies

9. UNIX for Dummies Questions & Answers

find and delete a file in one command

hi , let's assume i have a file that is located in the l*** directory and this file's name is t****_***s.php , how can i find this file and delete it using one single command ????? (3 Replies)
Discussion started by: wewee
3 Replies

10. Solaris

How to delete Directory and inside files using Find command

I am using the following Command to delete Directory with contents. But this command is deleting inside files only not directories. is there any change need in my command? find -type f -mtime +3 -exec rm -r {} \; Thanks (3 Replies)
Discussion started by: bmkreddy
3 Replies
Login or Register to Ask a Question