运行man touch,文中说-d 后面的date字符串格式为:原文引用
DATE STRING
The --date=STRING is a mostly free format human readable date string
such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or
even "next Thursday". A date string may contain items indicating cal-
endar date, time of day, time zone, day of week, relative time, rela-
tive date, and numbers. An empty string indicates the beginning of the
day. The date string format is more complex than is easily documented
here but is fully described in the info documentation.
我在虚拟机fedora 13上操作如下:
[root@fedora13 ~]# touch -d "2012-1-1 12:05:30" test.txt
[root@fedora13 ~]# ll
总用量 80
-rw-------. 1 root root 1679 8月 28 00:50 anaconda-ks.cfg
-rw-r--r--. 1 root root 53303 8月 28 00:49 install.log
-rw-r--r--. 1 root root 11826 8月 28 00:46 install.log.syslog
-rw-r--r-- 1 root root 12 1月 1 2012 test.txt
用touch修改test.txt文件的时候后,用ll显示,怎么这个文件显示的时间跟其他文件的不同呢?
sleeyoyo 于 2010-10-11 16:24:14发表:
[i=s] 本帖最后由 sleeyoyo 于 2010-10-11 16:30 编辑 [/i]
这样就一样了:
ls -l --time-style='+%D %R'
默认不是最近的时间(一年之外)显示年月日,一年之内显示月日时分
info ls看看:
By default, file timestamps are listed in abbreviated form. Most
locales use a timestamp like `2002-03-30 23:45'. However, the default
POSIX locale uses a date like `Mar 30 2002' for non-recent timestamps,
and a date-without-year and time like `Mar 30 23:45' for recent
timestamps.
deepwhite 于 2010-10-11 13:20:27发表:
不是被你 touch 过了么? touch 会修改文件的访问时间,将这个时间设置为你设置的值。当然就会变得不同了。