The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
searching content of files in the current and sub directories tiger99 Shell Programming and Scripting 4 01-23-2008 12:11 AM
searching files through all subdirectories beneath the current directory milagros Shell Programming and Scripting 5 05-15-2007 01:00 PM
ls latest 4 days or specify days of files in the directory happyv Shell Programming and Scripting 3 01-22-2007 04:16 AM
How to zip a modified file 15 days before but not scanning my sub directory files skrish70 Shell Programming and Scripting 1 10-10-2005 12:41 PM
Removing files automatically from a directory after 30 days. justinb_155 Shell Programming and Scripting 7 06-24-2005 11:07 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-30-2003
Registered User
 

Join Date: Oct 2003
Posts: 5
Searching for files over 30 days old in current directory

May be a simple question for experts here....


I need to get the list of files older than 30 days in the current folder. I tried "find", but it searches recursively in all the sub directories.

Can I restrict the recursive search and extract the files only from current directory ?
Reply With Quote
Forum Sponsor
  #2  
Old 10-30-2003
Registered User
 

Join Date: Oct 2003
Location: mumbai,india
Posts: 20
to find file in DIR
use
find $DIR -type f -atime +30 -print
hope it will suffice
Reply With Quote
  #3  
Old 10-30-2003
oombera's Avatar
Registered User
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
See if this works:

find . -mtime +30 \( ! -name . -prune \)
Reply With Quote
  #4  
Old 10-30-2003
Registered User
 

Join Date: Oct 2003
Posts: 5
Both the above scripts are digging down the sub directories. Any other altrenative ?
Reply With Quote
  #5  
Old 10-31-2003
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
Try....
Code:
find $PWD -type f -mtime +30 -print|grep -Ev "$PWD/.*/"
Reply With Quote
  #6  
Old 10-31-2003
Registered User
 

Join Date: Oct 2003
Posts: 5
Thanks a lot Ygor, this one is working.

Again thanks everybody.
Reply With Quote
  #7  
Old 10-31-2003
oombera's Avatar
Registered User
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Hmm... the -prune option is supposed to be what prevents going into subdirectories! At least, it works on ksh... what shell are you using? Ygor had a great work-around idea, but I'd think it would be faster if there's a ton of subdirectories to use -prune, rather than grabbing all the files in all the subdirectories, then eliminating everything except the current directory.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
mtime, regex, regular expressions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0