Solved

Remove Files from a directory which are two months old

Posted on 2006-07-04
6
521 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CPU monthly average? 12 138
What are recommended OS for exim mail server? 10 119
How can i set a Environment Variable in my Unix script ? 3 82
awk sed 8 106
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 …
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

749 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