Touch命令

touch介绍
将每个文件的访问和修改时间更新为当前时间。除非提供-c或-h,否者将不存在的FILE参数创建为空

touch参数格式
touch [OPTION] … FILE

touch命令参数
参数 释义
-a 或–time=atime或

–time=access或

–time=use

只更改存取时间
-c或–no-create 不建立任何文档
-d 使用指定的日期时间,而非现在的时间
-f 此参数将忽略不予处理,仅负责解决BSD版本touch指令的兼容行性问题。
-m或–time=mtime

或–time=modify

只更改变动时间
-r 把指定文档或目录的日期时间,统统设成和参考文档或目录的时间相同
-t 使用指定的日期时间,而非现在的时间

touch用法示例

touch test1 test2 test3 //创建三个测试文件

touch -c test4 // 不创建文档

ls //我们能可以看到 只有我们一开始创建的三个测试文件

test1 test2 test3
touch -t 202001060000 test1

stat test* //stat可以查看文件的详细变更时间

File: ‘test1’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 326740 Links: 1
Access: (0644/-rw-r–r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2020-01-06 00:00:00.000000000 +0800
Modify: 2020-01-06 00:00:00.000000000 +0800
Change: 2020-01-07 00:40:04.916746826 +0800
Birth: -
File: ‘test2’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 326741 Links: 1
Access: (0644/-rw-r–r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2020-01-07 00:38:36.672750610 +0800
Modify: 2020-01-07 00:38:36.672750610 +0800
Change: 2020-01-07 00:38:36.672750610 +0800
Birth: -
File: ‘test3’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 326742 Links: 1
Access: (0644/-rw-r–r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2020-01-07 00:38:36.672750610 +0800
Modify: 2020-01-07 00:38:36.672750610 +0800
Change: 2020-01-07 00:38:36.672750610 +0800
Birth: -

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值