1. Introduction to Commands
The Touch command changes the access time and modification time for each file to the current time.
2. Usage
Touch [Options] ... File...
3. Options
-A only change the access time -C,--no- Create creates no file -D,--Date= string Use the specified string to represent the time instead of the current time -F (Ignore)-H,--no-dereference affects the symbolic link itself, not the destination indicated by the symbolic link (This option is useful when the system supports changing the owner of a symbolic link .) -m only changes the modified time -R, the--reference= file uses the specified file's time attribute instead of the current time -t STAMP uses the [ [CC] YY]MMDDHHMM[.SS] Format time instead of the current time -time=word using WORD: Access, atime, use equals-the effect of the-a option , while modify, Mtime equals The effect of the-m option
4. Instance 1: Create an empty file in the current directory A.log
Touch010 April : A.log
Example 2: Update A.log modification time is current time
0 1 0 April :touch01 0 April : A.log
Example 3: Update Log1.log time and Log2.log timestamp same
[[email protected] dir1]# ll total dosage0-rw-r--r--1Root root0April - +: ,A.log-rw-r--r--1Root root0April - +: AB.log[[email protected] dir1]#Touch-r a.log B.log [[email protected] dir1]# ll total dosage0-rw-r--r--1Root root0April - +: ,A.log-rw-r--r--1Root root0April - +: ,B.log
Example 4: Setting the timestamp of a file
[[email protected] dir1]# ll total dosage0-rw-r--r--1Root root0April - +: ,A.log[[email protected] dir1]#Touch-T201601011200.50Log.log[[email protected] dir1]# ll total dosage0-rw-r--r--1Root root0April - +: ,A.log-rw-r--r--1Root root0January1 A:xxLog.log
One Linux command per day (9): Touch