1. Introduction
Change the time of the file or directory, you can update the file access time (Atime, the time when the contents of the file will be changed when the content is read) and the change time (Mtime, the content of the file will change the time)
2. Syntax and parameters
touch [parameters] [file or directory]
The Touch command creates an empty file when the file does not exist , but does not provide the-C or-H parameter after the touch command
1.-a,--time=atime,--time=access,--time=use
Change only the read time of a file
2.-c,--no-create
Do not create any files
3.-d,--date=string
Use the specified date time instead of the current time, and string is the format of the date.
For example:
[Email protected]:~/c#ls-L A.C-rwxrw-r--1Root root -The - -: $A.c[email protected]:~/c#Touch--Date="2017-4-1 23:23:23"A.c[email protected]:~/c#ls-L A.C-rwxrw-r--1Root root -Apr1 at: atA.c[email protected]:~/c#ls-L-- Time=CTime A.C-rwxrw-r--1Root root -Sep7 -: AA.c
Note: By default, LS displays the mtime of the file or directory.
The mtime of the first file is 8.30,t with touch modified to April 21, 2016, because the touch command changed the properties of the file, so the file's CTime (status time, the state of the file, When a file's properties or permissions are modified, it becomes the latest current time.
4.-F, this parameter is ignored and does not give any processing
5.-m,--time=mtime,--time=modify changes only time (Mtime)
6.-T STAMP uses the specified time in [[CC]YY]]MMDDHHMM[.SS] format instead of the current time
7.-r,--reference=file the time to use this file instead of the current time
Linux Command Touch