Saturday, December 8, 2007
Find files between two dates
To print all the files from 19-10-2007 to 21-11-2007
$ find . -type f -exec ls -l --time-style=full-iso {} \; | awk '{print $6,$NF}' | awk '{gsub(/-/,"",$1);print}' | awk '$1>= 20071019 && $1<= 20071121 {print $2}'
And to print all files from 2nd Nov 2007 to today, (Using -mtime with find command , and calculating the mtime based on the epoch times.)
$ FROM=`date --date='11/2/2007' +%s`
$ TO=`date +%s`
$ find /home/jsaikia/harness/rough/ -type f -mtime -`echo "(((($TO - $FROM ) / 24) / 60) / 60)" | bc` -print
If anyone got any better idea, please put in the comment section below.
Subscribe to:
Post Comments (Atom)
© Jadu Saikia www.UNIXCL.com
4 comments:
I will script
find . -newermt "2011-04-01 16:00:00" ! -newermt "2011-08-01 23:00:00"
@Luis, thanks, its useful.
Hi in sh shell it showing unrecognized -newermt....please advise
Hi Luis,
When i tried to use the -newermt in sh shell i m getting unrecognized newermt
please advise on what could be the issue
Post a Comment