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

  Unix/Linux 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 Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 07-24-2006
Shivdatta Shivdatta is offline
Registered User
 
Join Date: Mar 2006
Last Activity: 7 January 2015, 3:22 AM EST
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 Unix and Linux 07-24-2006
tayyabq8's Unix or Linux Image
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 9 Times in 3 Posts

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

Sponsored Links
    #3  
Old Unix and Linux 07-24-2006
Shivdatta Shivdatta is offline
Registered User
 
Join Date: Mar 2006
Last Activity: 7 January 2015, 3:22 AM EST
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 Unix and Linux 07-24-2006
tayyabq8's Unix or Linux Image
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 9 Times in 3 Posts
Try:
Code:
find . ! -newer aaa -print | sed -e 's_^./__'

where" __ " is double underscore.
Sponsored Links
    #5  
Old Unix and Linux 07-24-2006
Shivdatta Shivdatta is offline
Registered User
 
Join Date: Mar 2006
Last Activity: 7 January 2015, 3:22 AM EST
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 Unix and Linux 07-24-2006
tayyabq8's Unix or Linux Image
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 9 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 10:11 AM.