Linux find files in specific date range and zip it

Published by jackoonadmin in Linux on November 13th, 2012 | No Comments »

Use the command below to find files from specific date range

#find . -type f -newermt "2012-11-01" ! -newermt "2012-11-30"

Output:

./testfile.txt
./testfile2.txt

We can use the command to zip all the files we found, here we added a -printf command to just print out the exact file name only without “./” symbol

#gzip $(find . -type f -printf "%f\n" -newermt "2012-11-01" ! -newermt "2012-11-30")

 

reference: http://www.commandlinefu.com/commands/view/8721/find-files-in-a-date-range

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© Jackoon.com
CyberChimps