linux touch 多级目录,Linux 常用命令 文件目录管理之touch

本文详细介绍了Linux中的touch命令,包括如何创建文件、更新文件的访问时间和修改时间,以及各种选项的用法,如`-a`、`-c`、`-m`等。通过示例演示了如何使用touch改变文件的时间属性,并解释了其语法和参数说明。
摘要由CSDN通过智能技术生成

常用命令:

文件目录管理

touch

1.命令

touch -- 创建文件,改变文件的访问时间和修改时间。

2.使用样例

touch test --创建文件,名为test;如果test文件存在,会将 test文件的上次访问和修改时间设置为当前日期和时间

andy@ubuntu:~/lhc$ touch test

andy@ubuntu:~/lhc$ ls

test

touch test1 test2 --同时创建多个文件,名为test1,test2;如果test1,test2文件存在,会将test1,test2文件的上次访问和修改时间设置为当前日期和时间

andy@ubuntu:~/lhc$ touch test1 test2

andy@ubuntu:~/lhc$ ls

00:01:20 10:10:20 linux test1 test.sh

00:01:32 20:01:32 test test2 Tmux

stat test --如何查看文件的访问时间,修改时间,例如查看文件test的状态

andy@ubuntu:~/lhc$ stat test

File: 'test'

Size: 0 Blocks: 0 IO Block: 4096 regular empty file

Device: 801h/2049d Inode: 395355 Links: 1

Access: (0664/-rw-rw-r--) Uid: ( 1000/ andy) Gid: ( 1000/ andy)

Access: 2016-11-19 10:10:37.227806791 +0800

Modify: 2016-11-19 10:10:37.227806791 +0800

Change: 2016-11-19 10:10:37.227806791 +0800

Birth: -

touch -a test --改变test文件的访问时间为当前时间,Access时间由2016-11-19 10:10:37 切换到2016-11-19 10:19:46

andy@ubuntu:~/lhc$ touch -a test

andy@ubuntu:~/lhc$ stat test

File: 'test'

Size: 0 Blocks: 0 IO Block: 4096 regular empty file

Device: 801h/2049d Inode: 395355 Links: 1

Access: (0664/-rw-rw-r--) Uid: ( 1000/ andy) Gid: ( 1000/ andy)

Access: 2016-11-19 10:19:46.302453173 +0800

Modify: 2016-11-19 10:10:37.227806791 +0800

Change: 2016-11-19 10:19:46.302453173 +0800

Birth: -

touch -c test --如果test文

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值