HomeSolarisSolaris system administrationCreate/Modify a UNIX File with an Arbitrary Timestamp

Create/Modify a UNIX File with an Arbitrary Timestamp

The touch command in UNIX creates a file if it does not exist or updates the modification time of an existing file to the current time. An option of the touch command allows the modification timestamp to be set to any arbitrary time.


To change the modification time (the time displayed in a long listing of the file) of a file called testfile to November 18, 2000, 2:30 PM, use the following command:

touch -t 200011181430

This will alter the modification time of an existing testfile or, if not present, will create an empty file with that timestamp.

The format of the timestamp is as follows:
[[CC]YY]MMDDhhmm [.SS]

Date and time elements in square brackets are optional. Thus, the minimum timestamp includes month, day, hour, and minute.

Quinn McHenry
Quinn McHenry
Quinn was one of the original co-founders of Tech-Recipes. He is currently crafting iOS applications as a senior developer at Small Planet Digital in Brooklyn, New York.
RELATED ARTICLES

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Recent Comments

Cleveland Furia on How to Clear Google Activity
Sid Wohlfarth on How to Clear Google Activity
Riley Magsayo on How to Clear Google Activity
สมัครรับเครดิตฟรี ทันที on How to improve Remote Desktop Protocol Performance
Neal Wangstad on How to Clear Google Activity
Slavcho Andov on How to install Ubuntu
Slavcho Andov on How to fix bad sectors
Sheraz Ali on How to Backup Android