永久更改 ls 的日期/时间格式

Nif*_*fle 4 bash

当我这样做时,ls -l我得到

-rw-------  1 nifle None  17K Jul 15 01:48 .bash_history
-rwxr-xr-x  1 nifle None 1.2K Feb  9  2010 .bash_profile*
-rwxr-xr-x  1 nifle None 3.7K Mar 22 10:03 .bashrc*
-rwxr-xr-x  1 nifle None 3.7K Feb  9  2010 .bashrc~*
drwxr-xr-x+ 1 nifle None    0 Mar  6 17:31 .cpan/
drwxr-xr-x+ 1 nifle None    0 Jan  3  2011 .emacs.d/
 <snip>
Run Code Online (Sandbox Code Playgroud)

如何让日期/时间格式始终被YYYY-MM-DD HH:MM插入?

Ign*_*ams 13

假设 GNU ls,来自info ls "Formatting file timestamps"

`--time-style=STYLE'
     List timestamps in style STYLE.  The STYLE should be one of the
     following:
Run Code Online (Sandbox Code Playgroud)

...

`long-iso'
      List ISO 8601 date and time in minutes, e.g., `2002-03-30
      23:45'.  These timestamps are shorter than `full-iso'
      timestamps, and are usually good enough for everyday work.
      This style is equivalent to `+%Y-%m-%d %H:%M'.
Run Code Online (Sandbox Code Playgroud)

...

   You can specify the default value of the `--time-style' option with
the environment variable `TIME_STYLE'; if `TIME_STYLE' is not set the
default style is `locale'.
Run Code Online (Sandbox Code Playgroud)

因此,将以下内容放入您的.bashrcor 中.bash_profile,您就完成了:

export TIME_STYLE=long-iso
Run Code Online (Sandbox Code Playgroud)

  • http://mywiki.wooledge.org/ParsingLs (2认同)