Posts Tagged ‘timestamp’

How to duplicate a file with the current date and time

Tuesday, September 29th, 2009

To duplicate (backup) a file as filename.unixtimestamp use

cp myfilename{,.`date +%s`}

You can change the date format as per your preference. Below would duplicate it as filename.yyyymmdd

cp myfilename{,.`date +%Y%m%d`}

To find all files modified after a certain date and time

Tuesday, September 29th, 2009

To find all files (regular files) modified after 12:00 AM today use

touch -t `date +%Y%m%d0000` /tmp/mintimestamp
find /path/to/search/for -type f -newer /tmp/mintimestamp
rm /tmp/mintimestamp

The trick is to timestamp /tmp/mintimestamp with the timestamp that we want to compare against.

So you would use the touch command below in the above set of commands to find all files modified after 12:00 AM on Jan 1, 2008:

touch -t `date 200801010000` /tmp/mintimestamp