命令名称:touch
命令所在路径:/bin/touch
执行权限:所有用户
语法:touch[文件名]
功能描述:创建空文件
范例:
$ touch newfile
$ touch file1 file2 file3
touch是创建空文件的命令,可以在当前目录下创建,可以指定路径(包括觉得路径/相对路径)创建.
1, touch newfile 创建单个文件
![001f95eeb1817180630d551d9e004708.png](https://i-blog.csdnimg.cn/blog_migrate/698cceecd5010089bd97e666a584ca97.jpeg)
2, touch newfile1 newfile2 newfile3.... 同时创建多个文件,文件和文件之间用空格隔开
![aea203901928004407ba94a19625ead1.png](https://i-blog.csdnimg.cn/blog_migrate/27c08d68384dfca68f547ba0666e7142.jpeg)
3, touch /tmp/newfile 指定路径下(/tmp)创建单个文件
![c162183743fd2330c149cfffc48bea76.png](https://i-blog.csdnimg.cn/blog_migrate/20caccfdd52c57b4f54df9d1ba5f9150.png)
4, touch /tmp/{newfile1,newfile2...} 指定路径同时创建多个文件
![403e8aba2c56f62f88af91ae7528aff2.png](https://i-blog.csdnimg.cn/blog_migrate/2863d85ab24035b6ac7dde44130f2cab.jpeg)
5, 除以上可以创建文件外,还可以针对已存在的文件,变更其m-time时间等, 用法为
touch -m filename (filename为已存在的文件, 执行此命令时, 文件内容不变, 但是m-time会发生改变, m-time后续文章会详细介绍, 这里仅做了解)
![0d97df28ff9aa465c23a513e15084973.png](https://i-blog.csdnimg.cn/blog_migrate/ca0798b5037c4a7df08e8aa145ae6380.jpeg)
以上是关于touch的常用方法介绍,更多内容可以通过man touch或者touch --help来获取.