How to change file's timestamp?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I need to write a script to change a file's timestamp. I have this script mytmp:

#!/bin/sh
cd /tmp/test
touch t1

Then, if I run mytmp, file t1 is created with the current timestamp.  How to
change its timestamp in the script after it is created to a specific date and
time? If I want to set the date and time as an argument, e.g. I change the
script as:

#!/bin/sh
newstmp=$1
cd /tmp/test
touch t1

and run it as

# mytmp "Tue Aug 22 08:30:00 CDT 2006"

What should be added in the script to change t1's timestamp to the argument
provided?

Thanks!

Hongwei Li


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux