How to change specific timestamps?

094

To change specific timestamps of a file in Linux, you can use the touch command with the -t option, which allows you to specify the timestamp in a specific format. The format is [[CC]YY]MMDDhhmm[.ss], where:

  • CC - Century (the first two digits of the year)
  • YY - Year (the last two digits of the year)
  • MM - Month (01 to 12)
  • DD - Day of the month (01 to 31)
  • hh - Hour (00 to 23)
  • mm - Minute (00 to 59)
  • ss - Seconds (00 to 59, optional)

For example, to set the timestamp of a file named example.txt to March 15, 2023, at 14:30, you would use:

touch -t 202303151430 example.txt

This command will change the last modified and access timestamps of example.txt to the specified date and time.

0 Comments

no data
Be the first to share your comment!