4.1.4/5 linux文件管理 :文件属性操作 :文件创建/修改时间
touch命令
用途:更新文件的访问和修改时间
语法:
touch [-a] [-c] [-m] [-f] [Time] [-t Time] [file … | Dir ...]
注意:如果没知道time,默认当前时间
如果指定了不存在的文件,就会创建文件,除非是 -c
-a 改变访问时间,不改变修改时间
-c 如果不存在,也不创建
-f 尝试强制创建文件,不管文件的读写权
-m 更改修改时间,不更改访问时间
-t 指定时间 格式为[[CC][YY]MMDDhhmm[.SS]] CC年份前两位 , YY年份后两位
修改为当前时间
$ ls -al test.sh ##不需要指定时间
-rwxrwxrwx. 1 sgx sgx 382 Sep 28 11:33 test.sh
$ touch test.sh
$ ls -al test.sh
-rwxrwxrwx. 1 sgx sgx 382 Sep 30 15:47 test.sh
修改为指定时间
$ touch -t 101010101010 xx ##修改为指定时间
$ stat xx
File: ‘xx’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd02h/64770d Inode: 131445 Links: 1
Access: (0664/-rw-rw-r--) Uid: ( 1000/ sgx) Gid: ( 1000/ sgx)
Context: unconfined_u:object_r:user_home_t:s0
Access: 1010-10-10 10:10:00.000000000 +0805
Modify: 1010-10-10 10:10:00.000000000 +0805
Change: 2018-09-30 16:15:10.888964465 +0800
Birth: -