find files older than a given file | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

find files older than a given file

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-24-2006
Shivdatta Shivdatta is offline
Registered User
 
Join Date: Mar 2006
Last Activity: 20 May 2014, 1:42 AM EDT
Posts: 104
Thanks: 0
Thanked 1 Time in 1 Post
find files older than a given file

I want to find out the files that are older than a given file in the current
directory ...Can anyone help
Sponsored Links
    #2  
Old 07-24-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Ex-Moderator
 
Join Date: Nov 2004
Last Activity: 16 December 2013, 12:55 AM EST
Location: Bahrain
Posts: 592
Thanks: 3
Thanked 8 Times in 3 Posts

Code:
find . ! -newer ./yourfile -print

Sponsored Links
    #3  
Old 07-24-2006
Shivdatta Shivdatta is offline
Registered User
 
Join Date: Mar 2006
Last Activity: 20 May 2014, 1:42 AM EDT
Posts: 104
Thanks: 0
Thanked 1 Time in 1 Post
thanks buddy !! but it also prints the file itself ( yourfile)which acts as the input.....also it gives output as this
-------------
.
./a.txt
./b.txt
----------

can i avoid the "./ "
    #4  
Old 07-24-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Ex-Moderator
 
Join Date: Nov 2004
Last Activity: 16 December 2013, 12:55 AM EST
Location: Bahrain
Posts: 592
Thanks: 3
Thanked 8 Times in 3 Posts
Try:
Code:
find . ! -newer aaa -print | sed -e 's_^./__'

where" __ " is double underscore.
Sponsored Links
    #5  
Old 07-24-2006
Shivdatta Shivdatta is offline
Registered User
 
Join Date: Mar 2006
Last Activity: 20 May 2014, 1:42 AM EDT
Posts: 104
Thanks: 0
Thanked 1 Time in 1 Post
Well that works fine !! is _(underscore) a substitute for "/" in sed command.
As sed has the following syntax sed -e 's/a/b'
Sponsored Links
    #6  
Old 07-24-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Ex-Moderator
 
Join Date: Nov 2004
Last Activity: 16 December 2013, 12:55 AM EST
Location: Bahrain
Posts: 592
Thanks: 3
Thanked 8 Times in 3 Posts
Yes "_" is delimiter here, I used it because "/" was in our search string also, so to avoid confusion it was "_" there, you can use any character as delimiter, but you have to take care of it in your syntax later on.

Regards,
Tayyab
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find files older than X with a weird file format MickAAA Shell Programming and Scripting 2 12-16-2010 10:07 PM
Find the number of files older than 1 day from a dir NARESH1302 Shell Programming and Scripting 10 12-16-2010 11:17 AM
find files older than and containing then tar. Ikon Shell Programming and Scripting 3 11-06-2009 01:36 PM
Find files older than x days and create a consolidated single tar file. Dawn Bosch Solaris 3 09-09-2008 05:45 AM
Find files older than 20 days & not use find halo98 Shell Programming and Scripting 2 05-18-2006 02:19 PM



All times are GMT -4. The time now is 08:14 AM.