Computing.Net > Forums > Unix > Unix cmd for find and remove

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Unix cmd for find and remove

Reply to Message Icon

Name: Katie
Date: August 10, 2001 at 05:52:57 Pacific
Comment:

I look for the Unix command that remove the files from the current directory which are more than 7 days old.
Could you help me.

Thanks in advance



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: August 11, 2001 at 02:22:04 Pacific
Reply:

You can use the 'find' command for this. I don't remember the syntax for how to do this but have an example at work.

I'll look next time I go in. Probably tomorrow but possibly not until Monday.


0

Response Number 2
Name: Don Arnett
Date: August 11, 2001 at 02:26:45 Pacific
Reply:

The answer to a post about 4 below this has the basics of what you want to do. See:

http://www.computing.net/unix/wwwboard/forum/2372.html (Need Help writing UNix script)

Note the -atime parameter, there are other parameters that can be used to check different types of time. For example, -ctime checks the create time I believe and mtime checks the last modified time, etc.


0

Response Number 3
Name: Siva
Date: August 14, 2001 at 20:50:44 Pacific
Reply:

This will delete all the files accessed more than 7 days ago.

find -depth -atime +7 -exec rm {} ;

Before you run the above replace rm with
ls -l and run to see what files will be deleted.

good luck


0

Response Number 4
Name: James Boothe
Date: August 27, 2001 at 15:43:22 Pacific
Reply:

The first parameter needs to be pathname (which is a dot in following example to specify the current directory). And the semicolon will need to be escaped by preceeding it with a backslash:
find . -depth -atime +7 -exec rm {} \;


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Unix cmd for find and remove

Your Advice:CMD for cksum and filen www.computing.net/answers/unix/your-advicecmd-for-cksum-and-filen/7498.html

Using find -exec and grep possible? www.computing.net/answers/unix/using-find-exec-and-grep-possible/5745.html

Unix Driver for HPLaserJet 1100xi www.computing.net/answers/unix/unix-driver-for-hplaserjet-1100xi/2033.html