常用命令:
文件目录管理
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文