让 ls -l 更易读的时间格式

2023-10-22 15:56:29 浏览数 (1)

ls -l 变更前

代码语言:javascript复制
[root@VM-centos ~]# ls -l
total 168
drwxr-xr-x  2 root root   4096 May  6 16:51 code_bak
-rwxr-xr-x  1 root root 129424 Jan 27  2016 dig
drwxr-xr-x  2 root root   4096 Apr 27  2021 docker
drwxr-xr-x  9 root root   4096 May  6 16:20 download
drwxr-xr-x  4 root root   4096 Dec 23 11:50 go
drwxr-xr-x  6 root root   4096 Jul  7  2021 lib
drwxrwxr-x 20 root root   4096 Jul  7  2021 libiconv-1.16
drwxr-xr-x  2 root root   4096 Jul  7  2021 services

alias 配置进入终端,自动生效

代码语言:javascript复制
[root@VM-centos ~]# echo "alias ll='ls -rtlh --time-style " %Y-%m-%d %H:%M:%S"'">>~/.bashrc
[root@VM-centos ~]# . ~/.bashrc

ll 看效果,易读了许多

代码语言:javascript复制
[root@VM-centos ~]# ll
total 168K
-rwxr-xr-x  1 root root 127K 2016-01-27 20:55:56 dig
drwxr-xr-x  2 root root 4.0K 2021-04-27 16:39:29 docker
drwxrwxr-x 20 root root 4.0K 2021-07-07 19:56:51 libiconv-1.16
drwxr-xr-x  6 root root 4.0K 2021-07-07 19:57:30 lib
drwxr-xr-x  2 root root 4.0K 2021-07-07 20:22:04 services
drwxr-xr-x  4 root root 4.0K 2021-12-23 11:50:11 go
drwxr-xr-x  9 root root 4.0K 2022-05-06 16:20:45 download
drwxr-xr-x  2 root root 4.0K 2022-05-06 16:51:53 code_bak

ls --help 参数解释

代码语言:javascript复制
-r, --reverse              reverse order while sorting
-t                         sort by modification time, newest first
-l                         use a long listing format
-h, --human-readable       with -l, print sizes in human readable format
                               (e.g., 1K 234M 2G)
--time-style=STYLE         with -l, show times using style STYLE:
                               full-iso, long-iso, iso, locale, or  FORMAT;
                               FORMAT is interpreted like in 'date'; if FORMAT
                               is FORMAT1<newline>FORMAT2, then 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

0 人点赞