touch命令 | 您所在的位置:网站首页 › 在tmp目录下新建目录abc指令 › touch命令 |
一、命令详解
1.1【功能说明】
touch命令有两个功能:一是创建新的空文件,二是改变已有文件的时间戳属性。 1.2【语法格式】 [root@7bfe451a2fe1 ~]# touch --help Usage: touch [OPTION]... FILE... Update the access and modification times of each FILE to the current time.说明: 注意区分touch和mkdir命令的功能,mkdir命令是创建空目录,touch是创建空文件在Linux中,一切皆文件,touch命令不能创建目录,但是可以个性目录的时间戳 二、使用范例 2.1 一次创建多个文件 # 结合大括号实现批量创建文件 touch stu{01..05} 2.2 更新文件的时间属性 touch a.txt stat a.txt touch -a a.txt echo 1>a.txt touch -m a.txt stat a.txtstat命令查看时间戳 [root@7bfe451a2fe1 ~]# stat anaconda-ks.cfg File: 'anaconda-ks.cfg' Size: 3345 Blocks: 8 IO Block: 4096 regular file Device: a4h/164d Inode: 142278 Links: 1 Access: (0600/-rw-------) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2020-11-13 01:58:18.000000000 +0000 Modify: 2020-11-13 01:58:18.000000000 +0000 Change: 2022-11-02 05:06:19.003645000 +0000 Birth: -说明: Access 最后访问文件的时间Modify 最后修改文件的时间Change 最后改变文件状态的时间ls命令查看时间戳 # atime:最后访问时间,查看文件内容时,文件的访问时间会改变 [root@7bfe451a2fe1 ~]# ls -lu total 4 -rw------- 1 root root 3345 Nov 13 2020 anaconda-ks.cfg # mtime:最后修改时间,修改文件内容,文件的修改时间会改变 [root@7bfe451a2fe1 ~]# ls -lt total 4 -rw------- 1 root root 3345 Nov 13 2020 anaconda-ks.cfg # ctime:状态改变时间,修改文件内容、移动文件或改变文件属性等文件的change时间会改变 [root@7bfe451a2fe1 ~]# ls -lc total 4 -rw------- 1 root root 3345 Nov 2 05:06 anaconda-ks.cfg 四、命令总结暂时没有遇到这个命令的实用场景 |
CopyRight 2018-2019 实验室设备网 版权所有 |