Touch create file or update file timestamp
Format: Touch parameter file name
Parameters:
-C: Do not create a file that does not exist
-M: Update only modified time, not update access time
-A: Update access time only, not update modification time
-R file: Time to update files using file files
-T: Modifies the time to the date specified by the parameter, such as 01091135 for January 9 11:35
Additional Knowledge: View file information (created date): Ls-l View file information (access date): Ls-lu
[[email protected] 123]# tree //confessed to the experimental environment, which has the following folders and files .├── 1234│ └── 12345├── 1.txt├── 2├── 2.txt└── 3.txt2 directories, 4 files[[email protected] 123]# touch -c a.txt //If there is a.txt, update its timestamp, and if not, do not create [[email protected] 123]# ls1234 1.txt 2 2.txt 3.txt[[email protected] 123]# ls -l 1. Txt-rw-r--r--. 1 root root 9 May 4 15:04 1.txt[[email Protected] 123]# touch -c 1.txt[[email protected] 123]# ls -l 1. Txt-rw-r--r--. 1 root root 9 May 4 16:21 1.txt[[email protected] 123]# Ls -lu 1.txt-rw-r--r--. 1 root root 9 may 4 16:21 1. Txt[[email protected] 123]# touch -a 1.txt[[email protected] 123]# ls -lu 1.txt-rw-r--r--. 1 root root 9 may 4 16:23 1.txt[ [Email protected] 123]# ls -l 2.txt-rw-r--r--. 1 root root 9 apr 5 05:17 2.txt[[email protected] 123]# touch -r 2.txt 1.txt[[email protected] 123]# ls -l 2.txt-rw-r--r--. 1 root root 9 Apr 5 05:17 2.txt[[email protected] 123]# touch -t 03301259 1.txt[[email protected] 123]# ls -l 1.txt-rw-r--r--. 1 root root 9 mar 30 12:59 1.txt[[email protected] 123]#
This article is from the "Technical Achievement Dream" blog, please be sure to keep this source http://xuxiaoliang.blog.51cto.com/10882951/1922271
Linux timestamp management ——— Touch command