Touch
"function description": Linux touch commands are not commonly used, and are generally used when using make, to modify file timestamps, or to create a new file that does not exist. . the touch command parameter changes the date time of the document or directory, including access time and change time.
"Syntax format": touch [Options] ... File ...
"Option Parameters":
-A or--time=atime or--time=access or--time=use only change the access time.
-C or--no-create does not establish any documents.
-D uses the specified date time instead of the current time.
-F This parameter ignores non-processing and is responsible only for compatibility issues with BSD version touch directives.
-M or--time=mtime or--time=modify only change the change time.
-R Sets the date and time of the specified document or directory to the same date and time as the reference document or directory.
-T uses the specified date time instead of the current time.
"Practice Actions":
Instance one: Create a file that does not exist
Command:
T Ouch log2012.log log2013.log
Output:
[email protected] test]# Touch Log2012.log Log2013.log
[email protected] test]# LL
-rw-r--r--1 root root 0 10-28 16:01 log2012.log
-rw-r--r--1 root root 0 10-28 16:01 log2013.log
if Log2014.log does not exist, the file is not created
[Email protected] test]# touch-c Log2014.log
[email protected] test]# LL
-rw-r--r--1 root root 0 10-28 16:01 log2012.log
-rw-r--r--1 root root 0 10-28 16:01 log2013.log
Example two: Update Log.log the time and Log2012.log same time stamp
Command:
Touch-r Log.log Log2012.log
Output:
[email protected] test]# LL
-rw-r--r--1 root root 0 10-28 16:01 log2012.log
-rw-r--r--1 root root 0 10-28 16:01 log2013.log
-rw-r--r--1 root root 0 10-28 14:48 log.log
[Email protected] test]# touch-r log.log log2012.log
[email protected] test]# LL
-rw-r--r--1 root root 0 10-28 14:48 log2012.log
-rw-r--r--1 root root 0 10-28 16:01 log2013.log
-rw-r--r--1 root root 0 10-28 14:48 log.log
Example three: Setting the timestamp of a file
Command:
Touch-t 201211142234.50 Log.log
Output:
[email protected] test]# LL
-rw-r--r--1 root root 0 10-28 14:48 log2012.log
-rw-r--r--1 root root 0 10-28 16:01 log2013.log
-rw-r--r--1 root root 0 10-28 14:48 log.log
[Email protected] test]# touch-t 201211142234.50 log.log
[email protected] test]# LL
-rw-r--r--1 root root 0 10-28 14:48 log2012.log
-rw-r--r--1 root root 0 10-28 16:01 log2013.log
-rw-r--r--1 root root 0 2012-11-14 log.log
Description
-T time uses the value specified as a new value for the corresponding time stamp of the specified file. The time specified here is a decimal number in the following form:
[[Cc]yy] mmddhhmm[. SS]
Here, CC is the first two digits of the number of years, that is, "century"; 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, touch will limit the number of years Ccyy to 1969 (not included)--2068. MM is the number of months, DD is the number of days, HH is the number of hours (several), MM is the number of minutes, SS is the number of seconds. The set range of seconds here is 0--61, which can handle leap seconds. These numbers consist of a time in the time zone specified by the environment variable TZ. Due to system limitations, the time earlier than January 1, 1970 was wrong.
This article is from the "Cornerboy" blog, make sure to keep this source http://cornerboy.blog.51cto.com/10012663/1652179
Linux Small white-basic command-touch