
Linux 中的 touch 命令主要用于调整文件或目录的时间戳,包括访问时间和修改时间。如果目标文件不存在,则会自动创建一个新文件。
通过
ls -l
<pre class="brush:php;toolbar:false;">touch [-acfm][-d][-r] [-t][--help][--version][文件或目录…]
--no-create
--file
使用 "touch" 命令将文件 "testfile" 的时间属性更新为当前系统时间,操作如下:
<pre class="brush:php;toolbar:false;">$ touch testfile # 修改文件的时间戳
在执行该命令前,可通过 ls 命令查看原文件时间属性:
<pre class="brush:php;toolbar:false;">$ ls -l testfile # 查看文件原始时间 # 当前修改时间为 16:09 -rw-r--r-- 1 hdd hdd 55 2011-08-22 16:09 testfile
执行 touch 命令后再次查看该文件的时间信息:
<pre class="brush:php;toolbar:false;">$ touch testfile # 更新文件时间为当前系统时间 $ ls -l testfile # 查看更新后的时间 # 文件时间已更新为 19:53 -rw-r--r-- 1 hdd hdd 55 2011-08-22 19:53 testfile
当使用 touch 命令时,若指定文件名不存在,则会自动创建一个空文件。例如,在当前路径下创建名为 "file" 的空白文件,操作如下:
<pre class="brush:php;toolbar:false;">$ touch file # 创建名为“file”的空文件
以上就是linux修改文件时间戳是什么-touch命令使用与实例的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号