Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify the timestamp of a file with touch command parameters in linux

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use touch command parameters in linux to modify the timestamp of a file", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to use the touch command parameter to modify the timestamp of a file in linux"!

The touch command parameter in linux is not commonly used, and it may be used when using make to modify the file timestamp or create a new file that does not exist. The following is how to use the touch command parameter in linux:

Touch [- acm] [- r ref_file (reference file) |-t time (time value)] file (file name)

Example:

Touch file1.txt updates the access and modification time of file1.txt

Touch-c file1.txt if file1.txt does not exist, do not create a file

Touch-r ref_file file1.txt updates file1.txt with the same timestamp as ref+file

The wrong time for the touch-t 0811142234.50 file1.txt setting file is 22:34:40 on November 14, 2008.

-a

Modify the access time of the file file.

-c

Do not create the file file.

-m

Modify the modification time of the file file

-r ref_file

Takes the value of the corresponding timestamp of the reference file ref_file as the new value of the specified file file timestamp.

-t time

Uses the specified time value time as the new value for the corresponding time stamp of the specified file file. The time here is specified as the decimal number ∶ in the following form

[[CC] YY] MMDDhhmm [.SS]

Here, CC is the top two of the years, that is, "centuries". YY is the last two digits of the number of years, that is, the number of years in a century. If the value of CC is not given, the touch command parameter in linux will limit the number of years CCYY to 1969 murmur2068. MM is the number of months, DD is the day, and the number of years CCYY is within 1969After 2068. MM is the number of months, DD is the number of days, hh is the number of hours (several points), mm is the number of minutes, SS is the number of seconds. This can handle leap seconds. The time composed of these numbers is one of the time zones specified by the environment variable TZ. Due to system limitations, a time earlier than January 1, 1970 is incorrect.

At this point, I believe you have a deeper understanding of "how to use touch command parameters to modify the timestamp of a file in linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report