Solved

Remove Files from a directory which are two months old

Posted on 2006-07-04
6
519 Views
Last Modified: 2012-08-13
Dear all i want to delete files that are two months old (Apr)  from  a directory
i tried the following
cd  name of that dir
find ./  -mtime +60 exec rm {} \;
i t gives  find  missing conjuction error

also i had tried find ./  -type f -ctime +60 |xargs rm -if
it returns the prompt but doesnt del the file

rm -if |ls -al |grep Apr
it returns # but doesnt del the files.
pls give the cmd if any one has


Thnx  in Adv
.............have a nice day ..............
0
Comment
Question by:harmsingh
6 Comments
 
LVL 24

Accepted Solution

by:
slyong earned 50 total points
ID: 17040571

Do:

$ cd /directory
$ find ./ -mtime +60 -exec rm {} \;

                              ^ there is a - for -exec
0
 
LVL 14

Expert Comment

by:ppfoong
ID: 17040765

In one line:

find /path/to/the/directory  -mtime +60 -exec rm {} \;

0
 
LVL 1

Expert Comment

by:tacticalvehicle
ID: 17044553
find ./  -mtime +60 -print
# this command is usefull if you want see wha you will delete
or
find ./  -mtime +60 -exec ls -la {}  \;
# another version for preview..
now you can change
this command to delete

find ./  -mtime +60 -exec rm {}  \;

mtime - modification time of INODE
available are also -ctime or -atime
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 48

Expert Comment

by:Tintin
ID: 17046285
mtime is not the modification time of the inode.  mtime referers to the last modification time of the file (which happens to be stored in the inode).  Only ctime refers to the modification of the inode itself.
0
 
LVL 6

Expert Comment

by:JJSmith
ID: 17047017

assuming that your original line was a paste:

find ./  -mtime +60 exec rm {} \;

then you have simply missed the leading - from exec;

find ./  -mtime +60 -exec rm {} \;

so your code was OK in the first place - just a typo

cheers
JJ
0
 

Author Comment

by:harmsingh
ID: 17047578
Thnks All

have a nice day...................


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Host issue and need to move VM's 2 241
LINUX ZIP - UNCOMPRESS WINDOWS PATH 3 88
unix solaris snoop command 6 85
Showing a username in UNIX and using that name in the script 4 16
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now