Find the directory modified/created before 4 days


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find the directory modified/created before 4 days
# 1  
Old 10-07-2009
Find the directory modified/created before 4 days

Hi,

I have an application which creates some directories while running. I want to delete these directories which are 4 days older.

i tried
Code:
find . type d -mtime +1 -print

And it is working fine..

but
Code:
find . type d -mtime +4 -print

is not giving any results which are 4 days old..

can anyone suggest a solution?
# 2  
Old 10-07-2009
find . -type d -mtime +4 -exec rm -rf {} \;

For more infos : Unix find command helper
# 3  
Old 10-07-2009
Ensure that you have directories you have created/modified 4 days before.

Put an ls of it and verify, also show here.
# 4  
Old 10-07-2009
Masanamuthu command suggestion is very very dangerous.
Consider the timestamp on say /var .
Code:
ls -lad /var

# 5  
Old 10-08-2009
I tried evrything possible by find... but still no success. These folders are created by an application(Espresso) each time it runs on various instances. In other directories of the same system it is ofcourse finding the directories which are 4 days old. but here its not.

Code:
find . -type d -atime  +1 -ctime  +1 -mtime  +1 -print

The above find prints all the directories which are 1 day old. But when i try to find directories which are 4 days old with the following..

Code:
find . -type d -atime  +4 -ctime  +4 -mtime  +4 -print

it is not listing anything bcoz of some unknown reason... (yes there are many folders which are 4 days old.. i checked it with 'ls -l'. its a huge list hence not posting here) It would be a great help if some one can help me to find another solution.. any help other than find would be appreciated...

Last edited by Tuxidow; 10-08-2009 at 08:41 AM..
# 6  
Old 10-08-2009
What Operating System and version?
Are you user "root"?
Do the following command find any directories:
Code:
find . -type d -mtime +4 -print
find . -type d -follow -mtime +4 -print

# 7  
Old 10-08-2009
Hi methyl.. Thanks for ur reply.. but both ur commands are not working.. but in other directories its working.. but only in this directory for some unknown reason its not showing any results even though there many directories which match the search criteria...

yes im root..

following is the linux version..
Code:
Linux version 2.4.9-e.57smp (gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-129.7.2))

do u have any other solution than find?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to find a file that's modified more than 2 days ago but less than 5 days ago?

How to find a file that's modified more than 2 days ago but was modified less than 5 days ago by use of any Linux utility ? (4 Replies)
Discussion started by: abdulbadii
4 Replies

2. UNIX for Dummies Questions & Answers

To find the latest modified file in a directory

I am trying to fetch the latest modified file from a directory using the command find . -type f -exec ls -lt \{\} \+ | head | awk '{print $9}' After the O/P, I get the below mentioned error and the command doesnt terminate at all. find: ls terminated by signal 13 find: ls terminated by... (2 Replies)
Discussion started by: Sree10
2 Replies

3. Shell Programming and Scripting

Find the sum of files created 5 days before

Hi, I want to find the sum of all the files created 5 days ago and store it in a variable. (os is HP-UX) can this be extracted from ls -l Is there any other way of getting the sum of all the files created (4 Replies)
Discussion started by: bang_dba
4 Replies

4. Shell Programming and Scripting

what is the find to command to find the files created last 30 days

what is the find to command to find the files created last 30 days (5 Replies)
Discussion started by: rajkumar_g
5 Replies

5. Shell Programming and Scripting

How to find the newly created directory

Hi, I need to create new directory by increasing the number by 1 of extracted lastly created directory. e.g. Log\out_log_1\ Log\out_log_2\ Log\out_log_3\ become Log\out_log_1\ Log\out_log_2\ Log\out_log_3\ Log\out_log_4\ Can anyone help how to do it in c-shell... (3 Replies)
Discussion started by: Andre_2008
3 Replies

6. Shell Programming and Scripting

Find unix file created how many days ago?

i want to find unix file created how many days ago? (4 Replies)
Discussion started by: utoptas
4 Replies

7. UNIX for Dummies Questions & Answers

How to find files created some days before?

HI, I have 2 questions. 1> Is there any code to see files that created some day or some time before in a directory??? 2> how or where i will find the last exit status of a process?? thanks (6 Replies)
Discussion started by: jyotidas
6 Replies

8. Shell Programming and Scripting

Find directories only and delete them created 3 days before

Hello I have some directories and files created under /export/local/user I would like to delete directories only under /export/local/user, created before 3 days Can someone help me with command to do this task? Thanks (4 Replies)
Discussion started by: needyourhelp10
4 Replies

9. Shell Programming and Scripting

perl find directory only if modified in last hour

I want a one liner perl command to find a directory only if the modified time is within the last hour I am running this on windows - and I will define a variable for the result. So for example I want to return value of 1 for the variable if the modified time of d:\test1 is within the last... (0 Replies)
Discussion started by: frustrated1
0 Replies

10. Shell Programming and Scripting

How to zip a modified file 15 days before but not scanning my sub directory files

I am using zip -m option to zip my files, but i dont want my sub directories files to be zipped (1 Reply)
Discussion started by: skrish70
1 Replies
Login or Register to Ask a Question