创建新文件:
$ ls -l /tmp/foo ls: /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/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/someotherfile