Change Date/Time of File Using Touch Command

Refer: http://askubuntu.com/questions/62492/how-can-i-change-the-date-modified-created-of-a-file

Find all the files in a directory and change date/time, even the script itself.

find -print | while read filename; do
# do whatever you want with the file
touch -t 201203101513 "$filename"
done

Change 2 hours from current time
touch -d "2 hours ago" filename

Change 2 hours from modify time of file itself
touch -d "$(date -R -r filename) - 2 hours" filename

Leave a Reply