user command:Touch-chang file Timestamps This command is rarely used
1. command format:
Touch [ options ] ... file
2. command parameters:
-A change only the access time just change the access time
-C do not create any files do not create any files
- D parse STRING and use it instead of currenttime parse the string and use it instead of the current time
- F Ignore
- h affect eachsymbolic link instead of any referenced file affect each symbolic connection, not the referenced file
- m change onlythe modification time just modify the time
- R Specifies the date and time of the document or directory to be set to the date and time corresponding to the reference document or directory
-T uses the specified date time instead of the current time
3 , command function:
Touch command parameters can change the date time of a document or directory, including access time and change time
4. Examples of use:
Example one: Creating Yema1.log and Yema2.log
Command:
[Email protected]~]# ls
51cto auto Baidu Install.log log2013.log test
Anaconda-ks.cfg auto1 baidu1 install.log.syslog log2014.log yema1
[Email protected]~]# Touch Yema1.log Yema2.log
[Email protected]~]# ll
Total 76
drwxr-xr-x.2 root root 4096 Dec 14:51 51cto
-RW-------. 1 root root 1295 Dec 23:32anaconda-ks.cfg
drwxr-xr-x.3 root root 4096 Dec 14:54 auto
drwxr-xr-x.2 root root 4096 Dec 14:58 auto1
drwxr-xr-x.2 root root 4096 Dec 10:19 Baidu
drwxr-xr-x.3 root root 4096 Dec 10:19 baidu1
-rw-r--r--. 1 root root 28865 Dec 23:32 Install.log
-rw-r--r--. 1 root root 7572 Dec 23:30install.log.syslog
-rw-r--r--. 1 root root 0 Dec 16:27log2013.log
-rw-r--r--. 1 root root 0 Dec 16:27log2014.log
drwxr-xr-x.2 root root 4096 Dec 09:51 test
drwxr-xr-x.3 root root 4096 Dec 09:45 yema1
-rw-r--r--. 1 root root 0 Dec 16:29 yema1.log
-rw-r--r--. 1 root root 0 Dec 16:29 yema2.log
[Email protected]~]# ls
51cto auto1 Install.log Log2014.log yema1.log
anaconda-ks.cfg Baidu Install.log.syslog Test Yema2.log
Auto BAIDU1 log2013.log yema1
If the yema3.log does not exist, do not create the file, using the-c parameter, the command is as follows:
[Email protected] ~]# touch-c Yema3.log
[email protected] ~]# LL
Total 76
Drwxr-xr-x. 2 root root 4096 Dec 14:51 51cto
-RW-------. 1 root root 1295 Dec 23:32 anaconda-ks.cfg
Drwxr-xr-x. 3 root root 4096 Dec 14:54 auto
Drwxr-xr-x. 2 root root 4096 Dec 14:58 auto1
Drwxr-xr-x. 2 root root 4096 Dec 10:19 Baidu
Drwxr-xr-x. 3 root root 4096 Dec 10:19 baidu1
-rw-r--r--. 1 root root 28865 Dec 23:32 Install.log
-rw-r--r--. 1 root root 7572 Dec 23:30 install.log.syslog
-rw-r--r--. 1 root root 0 Dec 16:27 log2013.log
-rw-r--r--. 1 root root 0 Dec 16:27 log2014.log
Drwxr-xr-x. 2 root root 4096 Dec 09:51 test
Drwxr-xr-x. 3 root root 4096 Dec 09:45 yema1
-rw-r--r--. 1 root root 0 Dec 16:29 yema1.log
-rw-r--r--. 1 root root 0 Dec 16:29 yema2.log
Instance two: Update Yema1.log time and Yema2.log timestamp same
Using the-R parameter
The command is as follows:
[email protected] ~]# LL
Total 76
Drwxr-xr-x. 2 root root 4096 Dec 14:51 51cto
-RW-------. 1 root root 1295 Dec 23:32 anaconda-ks.cfg
Drwxr-xr-x. 3 root root 4096 Dec 14:54 auto
Drwxr-xr-x. 2 root root 4096 Dec 14:58 auto1
Drwxr-xr-x. 2 root root 4096 Dec 10:19 Baidu
Drwxr-xr-x. 3 root root 4096 Dec 10:19 baidu1
-rw-r--r--. 1 root root 28865 Dec 23:32 Install.log
-rw-r--r--. 1 root root 7572 Dec 23:30 install.log.syslog
-rw-r--r--. 1 root root 0 Dec 16:27 log2013.log
-rw-r--r--. 1 root root 0 Dec 16:27 log2014.log
Drwxr-xr-x. 2 root root 4096 Dec 09:51 test
Drwxr-xr-x. 3 root root 4096 Dec 09:45 yema1
-rw-r--r--. 1 root root 0 Dec 16:29 yema1.log
-rw-r--r--. 1 root root 0 Dec 16:29 yema2.log
This article is from the "Go to It" blog, make sure to keep this source http://518443.blog.51cto.com/508443/1597370
Linux CP Basic Command Summary