Operating System - HP-UX
1834252 Members
2212 Online
110066 Solutions
New Discussion

modify date-time of a file

 
Donald23
Occasional Advisor

modify date-time of a file

Hi,
Is there any way to modify the date-time of a existed file.
As I know, use "touch " you can do:
1. if the file is not existed, then system will create the file with 0 byte
2. if the file is existed, system will update the file's date-time to the current.
My question is if I wanna modify the date-time to 1 day before???
Donald
3 REPLIES 3
curt larson_1
Honored Contributor

Re: modify date-time of a file

use the -t switch of the touch command

-t time Use the specified time instead of the current time. The option argument is a decimal number of the form:

[[CC]YY]MMDDhhmm[.SS]

The following command sets the modification and access times of the file named "bastille" to midnight, July 14, 1989, creating the file if it does not already exist.

touch -t 8907140000 bastille
twang
Honored Contributor

Re: modify date-time of a file

twang
Honored Contributor

Re: modify date-time of a file

Add to above, 'touch -t' can only modify the last-access and modification timestamp(that is normally shown). You cannot modify the last i-node change time(change of permission), using the following command to show a file's last i-node change time:

# ls -cl