文件及目录操作 - touch、tree
1、touch:创建文件或更改文件时间戳
touch命令的功能说明
touch命令用于创建新的空文件或改变已有文件的时间戳属性。
touch命令的语法格式
touch [OPTION]... FILE...
touch [参数选项] [文件]
touch命令的选项说明
touch 选项不常用,就不细说了:
touch命令的实践操作
范例1: 创建文件(文件事先不存在的情况)
[root@oldboyedu ~]# mkdir -p /test
[root@oldboyedu ~]# cd /test
[root@oldboyedu /test]# ls
[root@oldboyedu /test]# touch oldboy.txt
[root@oldboyedu /test]# ls
oldboy.txt
[root@oldboyedu /test]# touch a.txt b.txt
[root@oldboyedu /test]# ls
a.txt b.txt oldboy.txt
[root@oldboyedu /test]# touch stu{1…4} <–>利用{ }有序序列批量创建文件
[root@oldboyedu /test]# ls
a.txt b.txt oldboy.txt stu1 stu2 stu3 stu4
范例1: 更改文件的时间戳属性
[root@oldboyedu /test]# stat oldboy.txt
File: ‘oldboy.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: 803h/2051d Inode: 51524120 Links: 1
Access: (0644/-rw-r–r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2019-04-06 19:00:34.447304058 +0800
Modify: 2019-04-06 19:00:34.447304058 +0800
Change: 2019-04-06 19:00:34.447304058 +0800
Birth: -
[root@oldboyedu /test]# touch -a oldboy.txt <–> -a 参数只更改文件的最后访问时间
[root@oldboyedu /test]# stat oldboy.txt
File: ‘oldboy.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty