The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find 3 months old log files and remove cvdev SUN Solaris 13 05-22-2008 01:38 PM
deleting files with dates 3 months ago godalle UNIX for Dummies Questions & Answers 3 11-08-2005 03:03 AM
Last modification times of files less than 6 months old Abhishek Ghose UNIX for Dummies Questions & Answers 1 10-19-2005 07:37 AM
Find files older than 5 days and remove tem after listing ypatel6871 UNIX for Dummies Questions & Answers 1 09-05-2005 11:00 AM
Recursive directory listing without listing files psingh UNIX for Dummies Questions & Answers 4 05-10-2002 10:52 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-15-2002
pbekal pbekal is offline
Registered User
  
 

Join Date: Jan 2002
Posts: 11
Listing files older than 2 months

A script or command to list files older than 2 months in a specified directory and remove it.
  #2 (permalink)  
Old 01-15-2002
thehoghunter
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Using the find command is one way - check the man page as there are examples.

Just be careful about removing files older than 2 months as a system files are normally older than two months and could also be removed.

find ./ -name "*" -ctime +60 -exec rm {} \;
You can use ctime, atime or mtime

(Important - don't get the last part wrong as very bad things can happen!!! Try it some time on a test system.)
  #3 (permalink)  
Old 01-16-2002
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
You should put some sort of qualifier in the -name option, like -name "*.logfile", depending on the naming scheme you're going for. If there isn't one, you can leave the -name "*" off altogether, as it will ignore any files beginning with "."... Unless that's what you're going for. It's also a good idea to simply move all the files to their own directory first, then examine them to make sure you aren't getting rid of anything important before removing them.
  #4 (permalink)  
Old 01-17-2002
sharad_marathe sharad_marathe is offline
Registered User
  
 

Join Date: Jan 2002
Posts: 3
I will create one file with timestamp two months back and
search for newer files.

eg.

#touch -t 0112310000 /xyz
#find / -newer /xyz -print -exec ls -ls {} \;

Refer manual pages of touch and find for mor info

Hope it helps

Regards

Sharad
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:24 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0