Linux touch命令详解
touch命令有两个功能:
一是用于把已存在文件的时间标签更新为系统当前的时间(默认方式),它们的数据将原封不动地保留下来;
二是用来创建新的空文件。
touch常见命令参数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | -a change only the access time -c, --no-create do not create any files -d, -- date =STRING parse STRING and use it instead of current time -f (ignored) -h, --no-dereference affect each symbolic link instead of any referenced file (useful only on systems that can change the timestamps of a symlink ) -m change only the modification time -r, --reference=FILE use this file 's times instead of current time -t STAMP use [[CC]YY]MMDDhhmm[.ss] instead of current time -- time =WORD change the specified time : WORD is access, atime, or use: equivalent to -a WORD is modify or mtime: equivalent to -m --help display this help and exit --version output version information and exit |
常用的命令展示
touch:创建file1—file10共10个文件
1 | touch file {1..10} |
设定文件的时间戳
touch -t 201810121230 hh.sh 【-t用十进制数】
更新log.log的时间和log2012.log时间戳相同
1 | touch -r hh hh.sh 【 touch -r目标文件 源文件】 |
作者:小a玖拾柒
-------------------------------------------
个性签名: 所有的事情到最後都是好的,如果不好,那說明事情還沒有到最後~
本文版权归作者【小a玖拾柒】和【博客园】共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利!
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步