Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

find files older than a given file

Shell Programming and Scripting


Closed    
 
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: 21 May 2016, 8:37 AM EDT
Location: Oman
Posts: 593
Thanks: 8
Thanked 12 Times in 5 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: 21 May 2016, 8:37 AM EDT
Location: Oman
Posts: 593
Thanks: 8
Thanked 12 Times in 5 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: 21 May 2016, 8:37 AM EDT
Location: Oman
Posts: 593
Thanks: 8
Thanked 12 Times in 5 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 Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 11:07 PM
Find the number of files older than 1 day from a dir NARESH1302 Shell Programming and Scripting 10 12-16-2010 12:17 PM
find files older than and containing then tar. Ikon Shell Programming and Scripting 3 11-06-2009 02:36 PM
Find files older than x days and create a consolidated single tar file. Dawn Bosch Solaris 3 09-09-2008 06:45 AM
Find files older than 20 days & not use find halo98 Shell Programming and Scripting 2 05-18-2006 03:19 PM



All times are GMT -4. The time now is 01:46 AM.