1、文件由元数据和数据组成,其中元数据包括访问时间、更新时间、修改时间、创建时间等
2、stat:display file or file system status
stat [OPTION]... FILE...
>>stat /tmp/
File: ‘/tmp/’
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: fd00h/64768d Inode: 134294600 Links: 18
Access: (1777/drwxrwxrwt) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-08-22 10:10:55.071954516 +0000
Modify: 2018-08-22 10:10:55.073954524 +0000
Change: 2018-08-22 10:10:55.073954524 +0000
Birth: -
3、修改文件时间戳
touch: change file timestamps
touch [OPTION]... FILE...
-a change only the access time
-c, --no-create , do not create any files ##修改(access,modify time)时间戳;文件不存在时也不创建文件
-m change only the modification time
-t STAMP ,use [[CC]YY]MMDDhhmm[.ss] instead of current time
示例:
>> touch file1 #修改文件时间戳,如果目标文件不存在,则创建
>> stat file1
File: ‘file1’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 135598097 Links: 1
Access: (0664/-rw-rw-r--) Uid: (56007/ vn0eco6) Gid: (56007/ vn0eco6)
Access: 2018-08-21 02:57:56.180571683 +0000
Modify: 2018-08-21 02:57:56.180571683 +0000
Change: 2018-08-21 02:57:56.180571683 +0000
Birth: -
>>touch -m file1 #修改modify time为当前时间
>>touch -t 201808081010.30 file1 #为modify time设置指定时间戳,change time 会随之而变
网友评论