Update file timestamp or create new file Touch
The document has three major change times:
Modification Time (mtime): updated when file content data is changed
Status Time (CTime): updated when file permissions and attributes are changed
Access Time (atime): updated when a file is accessed
Touch [-ACDMT] file
Parameters:
-A: Modify access time only
-C: only the time to modify the file, if the file does not exist, do not create a new file
-D:--date= Date and time specify the modified date and time to set
-M: modify mtime only
-T: the time format that can be modified after is [YYMMDDHHMM]
Example
#文件不存在则创建新的空文件 # ls The time that is displayed by default is the Mtime[[email protected] test]$ touch test_touch[[email of the file protected] test]$ lltotal 0-rw-rw-r--. 1 roger roger 0 Aug 25 10:49 test_touch #查看文件时间 [[email protected] test]$ stat test_touch File: ' Test_touch ' Size: 0 Blocks: 0 IO Block: 4096 regular empty fileDevice: fd01h/64769dInode: 1048609 Links: 1Access: (0664/-rw-rw-r--) Uid: ( 500/ Roger) Gid: ( 500/ roger) access: 2015-08-25 10:49:25.663413029 +0800modify: 2015-08-25 10:49:25.663413029 +0800change: 2015-08-25 10:49:25.663413029 +0800 # Review the contents of the file and update the Atime[[email protected] test]$ cat test_touch [[email protected] test]$ stat test_touch File: ' Test_touch ' size: 0 blocks: 0 io block: 4096 regular empty filedevice: fd01h/64769dInode: 1048609 Links: 1Access: (0664/-rw-rw-r--) Uid: ( 500/ roger) Gid: ( 500/ roger) access: 2015-08-25 10:55:47.721125941 +0800modify: 2015-08-25 10:49:25.663413029 +0800Change: 2015-08-25 10:49:25.663413029 +0800 # Atime and Mtime are updated to the specified time, ctime updated to the current time [[email protected] test]$ touch -t 1409111008 test_touch [[email protected] test]$ stat test_touch file: ' Test_touch ' Size: 0 Blocks: 0 io block: 4096 regular empty filedevice: fd01h/64769dInode: 1048609 Links: 1Access: (0664/-rw-rw-r--) Uid: ( 500/ roger) Gid: ( 500/ roger) access: 2014-09-11 10:08:00.000000000 +0800modify: 2014-09-11 10:08:00.000000000 +0800change: 2015-08-25 11:02:02.444495259 +0800
two features used by touch
1 Create an empty file
2 Modify a file date to the current date (mtime and atime)
If there is any mistake, please correct me!
Thank you!
Update file timestamp or create new File command