指令——touch

一个完整的指令的标准格式:

Linux通用的格式——#指令主体(空格) [选项](空格) [操作对象]

一个指令可以包含多个选项操作对象也可以是多个。

指令:touch   

作用:创建文件

语法:#touch 文件路径 [文件路径2  文件路径3  …]

~ 表示当前用户家目录


创建aa.txt到根目录下:

[root@localhost ~]# touch /aa.txt

[root@localhost ~]# ll /
总用量 24
-rw-r--r--.   1 root root    0 5月   8 22:16 1
-rw-r--r--.   1 root root    0 5月  11 10:11 aa.txt
lrwxrwxrwx.   1 root root    7 5月   8 21:58 bin -> usr/bin


[root@localhost ~]# touch /home/he/ss.txt
[root@localhost ~]# ls -lh /home/he
总用量 12K
-rw-rw-r--. 1 he   he     26 5月  11 08:53 1.txt
drwxrwxr-x. 2 he   he      6 5月  11 09:58 a
drwxrwxr-x. 2 he   he      6 5月  11 09:58 b
drwxrwxr-x. 2 he   he      6 5月  11 09:58 c
-rw-rw-r--. 1 he   he   2.6K 5月   9 17:08 e1.txt
-rwx--xr-x. 1 he   root 2.8K 5月  10 16:23 e.txt
-rw-r--r--. 1 root root    0 5月  11 10:15 ss.txt


如果文件的路径其中包含了不存在文件夹,是不能创建成功的。

在这种情形下是不支持类似于mkdir指令的-p选项的

原文地址:https://www.cnblogs.com/getbird/p/10847846.html