Function Description:
The Touch command parameter creates a new file and changes the date and time of the document or directory, including access time and change time.
Command format:
touch [Options] ... File...
Command 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.
Command case:
Case 1, create a new file
[email protected] miao]# Touch a.txt B.log
[email protected] miao]# LL
Total 0
-rw-r--r--1 root root 0 7 17:01 a.txt
-rw-r--r--1 root root 0 7 17:01 B.log
[Email protected] miao]#
Case 2, Update a.txt time and B.log timestamp are the same
[email protected] miao]# LL
Total 0
-rw-r--r--1 root root 0 7 17:06 A.log
-rw-r--r--1 root root 0 7 17:01 a.txt
-rw-r--r--1 root root 0 7 17:01 B.log
[Email protected] miao]# touch-r a.txt a.log
[email protected] miao]# LL
Total 0
-rw-r--r--1 root root 0 7 17:01 A.log
-rw-r--r--1 root root 0 7 17:01 a.txt
-rw-r--r--1 root root 0 7 17:01 B.log
[Email protected] miao]#
Case 3, set the timestamp of the file
[Email protected] miao]# touch-t 201408010000.00 a.log
[email protected] miao]# LL
Total 0
-rw-r--r--1 root root 0 1 00:00 a.log
-rw-r--r--1 root root 0 7 17:01 a.txt
-rw-r--r--1 root root 0 7 17:01 B.log
[Email protected] miao]#
Description: The time specified here is a decimal number in the following form: [[cc]yy]mmddhhmm[]. SS] Due to system limitations, the time earlier than January 1, 1970 was wrong.