Linux Touch Command Learning
Touch meaning: Creating files and modifying files
Touch format: Touch [options] file-list
Parameters
file-list is the file path name that touch will create or update
Options
-A only updates the access time and does not change the modification time
-C does not create files that do not exist
-M only updates the modification time, does not change the access time
-r file time to update files using file files
-T modifies the time to the date specified by the parameter, such as: 07081556 for July 8 15:56
Example
Touch Update already has file time
LS-:touchls-: £firefox_wallpaper.png
Touch no option to update the file's modification time and access time at the same time
Touch Create File
Touchls-:demo.c
touch-at Update access time with parameters
First look at the original modified time and access time, Ls-lu to see the access time
LS-all:wuyils-: £hs_err_pid2874.log
Next is the modified time and access time after the update.
01081010LS-£ º------hs_err_pid2874.log
As you can see, the modification time is not changed, but the access time changes
touch-m Update modification time only
$LS-L Total Dosage68-rw-r--r--1 Siu Siu66350 December2316:51 Hs_err_pid2874.log $ touch-m Hs_err_pid2874.log $ ls-l total usage 68-rw-r--r-- Span style= "COLOR: #800080" >1 Siu siu 66350 January 8 15:31 hs_err_pid2874.log$ ls-lu total usage 68-rw-r--r--1 Siu siu 8 10:10 hs_err_pid2874.log
As the above example shows, the access time here has not changed and the change time has changed
Tips
1. You can use the default current time to update the file's access time and modification time, or you can specify parameters to update
2. In general, the most place to touch is to create a new file
Linux Touch Learning