分页: 1 / 1

修改 ls -l 时间显示格式

发表于 : 2011-12-22 13:08
windwiny
使用 ls -l 看文件修改时间,经常出现 Dec, Jul 之类的东西,这东西它认识我,我不认识它啊
要是开了 LANG=zh 之类的在实控制台下又会出现 12口 4口之类的,显示又不正常。

一fire之下把所有locale都装上
for i in `locale -a` ; do
env LC_TIME=$i ls -l
echo $i
echo '-------------'
done
显示全部locale的时间格式

现在用 env LC_TIME=lt_LT ls -l 执行一下,时间显示成 2011-12-22 12:54 , 一看就清爽,一目了然~~
这个locale 又好记,小写lt,大写LT,也不知道哪个地区的

把这个东西写到 /etc/environment 或者自己的 .bashrc 里去,下次启动就OK了

Re: 修改 ls -l 时间显示格式

发表于 : 2011-12-23 11:59
YeLee
嗯,不错 :em11 :em11 :em11

Re: 修改 ls -l 时间显示格式

发表于 : 2012-05-18 16:05
xiaofenger.tan
呃~~
正确的好像是 TIME_STYLE 环境变量~~

Re: 修改 ls -l 时间显示格式

发表于 : 2012-05-18 18:06
Havanna
$ man ls

--time-style=STYLE
with -l, show times using style STYLE: full-iso, long-iso,
iso, locale, +FORMAT. FORMAT is interpreted like 'date'; if
FORMAT is FORMAT1<newline>FORMAT2, FORMAT1 applies to
non-recent files and FORMAT2 to recent files; if STYLE is
prefixed with 'posix-', STYLE takes effect only outside the
POSIX locale

$ ls -l --time-style=long-iso