本文给大家介绍了一些touch命令的用法。touch一般用来创建一个新文件。同时,touch还可以用来修改文件时间戳。创建新文件:$ ls -l /tmp/fools: /tmp/foo: No such file or directory$ touch /tmp/foo$ ls -l /tmp/foo-rw-r--r-- 1 andy wheel 0 Jul 10 11:56 /tmp/footouch还可以用来修改文件时间戳。
-t 参数可以指定要修改成的具体时间$ ls -l /tmp/fools: /tmp/foo: No such file or directory$ touch -t 201107010930 /tmp/foo$ ls -l /tmp/foo-rw-r--r-- 1 andy wheel 0 Jul 1 09:30 /tmp/foo若没有指定,则设置为当前时间:$ ls -l /tmp/foo-rw-r--r-- 1 andy wheel 0 Jul 1 09:30 /tmp/foo$ touch /tmp/foo$ ls -l /tmp/foo-rw-r--r-- 1 andy wheel 0 Jul 10 11:58 /tmp/fooYou can also use the timestamp from another file and apply it to another file by using the -r switch.$ ls -l /tmp/someotherfile-rw-r--r-- 1 andy wheel 0 Aug 12 2005 /tmp/someotherfile$ touch -r /tmp/someotherfile /tmp/foo /tmp/foo2 /tmp/foo3$ ls -al /tmp/-rw-r--r-- 1 andy wheel 0 Aug 12 2005 /tmp/foo-rw-r--r-- 1 andy wheel 0 Aug 12 2005 /tmp/foo2-rw-r--r-- 1 andy wheel 0 Aug 12 2005 /tmp/foo3-rw-r--r-- 1 andy wheel 0 Aug 12 2005 /tmp/someotherfileCentOS 5.4 通过yum升级PHP到5.3版本的两种方法Ubuntu 11.04 为不同工作分区设置相异壁纸相关资讯 Linux命令
- 48 字节命令可令 Linux 系统当机! (今 07:55)
- 在Linux笔记本上执行这句命令能致 (02月02日)
- .NET开发必会的Linux命令 (12/20/2015 10:32:03)
| - 运维工程师必会的109个Linux命令 (03月09日)
- 有趣的Linux命令行:随机输出唐诗 (12/28/2015 20:14:23)
- 10 个 Linux 中的 passwd 命令示例 (10/29/2015 10:14:30)
|
本文评论 查看全部评论 (0)