ls -d *
find . -type d -maxdepth 1
amosli@amosli-pc:~$ ls -d * %APPDATA% develop many sorted.txt workspace bank Documents Music space 下载
2. find . -type d -maxdepth 1
如果不加-maxdepth 参数的话那么将会有无穷多目录被列出来。
amosli@amosli-pc:~$ find . -type d -maxdepth 1 ./Videos ./Public ./%APPDATA% ./.kde ./.gnome2 ./Music
3.ls -F | grep ‘/$’
使用linux管道命令,grep查找 ‘/$’ 以/结尾的,也即是目录
amosli@amosli-pc:~$ ls -F | grep’/$’ %APPDATA%/ bank/ Desktop/ develop/ Documents/
4.ls -l | grep ‘^d’
amosli@amosli-pc:~$ ls -l | grep’^d’ drwxr-xr-x 3 amosli amosli 4096 6月 222013 %APPDATA% drwxr-xr-x 36 amosli amosli 4096 12月 2017:44 bank drwxr-xr-x 4 amosli amosli 4096 12月 2800:33 Desktop drwxrwxr-x 13 amosli amosli 4096 12月 2119:11 develop drwxr-xr-x 3 amosli amosli 4096 7月 900:58 Documents
命令:ls
详细解释:
-l use a long listing format 以长列表方式显示(详细信息方式)
-t sort by modification time 按修改时间排序(最新的在最前面)
-r reverse order while sorting (反序)
Linux:ls按照修改时间排序显示
# 按照时间降序
ls -lt
# 按照时间升序
ls -ltr
root@zabbix-unify:/# # 按照时间降序
root@zabbix-unify:/# ls -lt
total 0
drwxrwxrwt 1 root root 68 Nov 30 17:47 tmp
drwxr-xr-x 1 root root 43 Nov 26 13:39 run
drwxr-xr-x 16 root root 4020 Nov 26 13:39 dev
drwxr-xr-x 1 root root 77 Nov 26 13:39 apps
dr-xr-xr-x 1175 root root 0 Nov 26 13:39 proc
drwxr-xr-x 1 root root 20 Nov 26 13:39 etc
dr-xr-xr-x 13 root root 0 Nov 25 19:53 sys
dr-xr-xr-x 1175 root root 0 Nov 25 19:53 host
drwx------ 2 root root 37 Jun 9 15:31 root
drwxr-xr-x 1 root root 45 Jun 9 15:31 var
drwxr-xr-x 2 root root 6 Jun 9 15:27 media
drwxr-xr-x 2 root root 6 Jun 9 15:27 mnt
drwxr-xr-x 2 root root 6 Jun 9 15:27 opt
drwxr-xr-x 2 root root 6 Jun 9 15:27 srv
drwxr-xr-x 1 root root 19 Jun 9 15:27 usr
lrwxrwxrwx 1 root root 7 Jun 9 15:27 bin -> usr/bin
lrwxrwxrwx 1 root root 7 Jun 9 15:27 lib -> usr/lib
lrwxrwxrwx 1 root root 9 Jun 9 15:27 lib32 -> usr/lib32
lrwxrwxrwx 1 root root 9 Jun 9 15:27 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 10 Jun 9 15:27 libx32 -> usr/libx32
lrwxrwxrwx 1 root root 8 Jun 9 15:27 sbin -> usr/sbin
drwxr-xr-x 2 root root 6 Apr 15 2020 boot
drwxr-xr-x 2 root root 6 Apr 15 2020 home
root@zabbix-unify:/#
root@zabbix-unify:/# # 按照时间升序
root@zabbix-unify:/# ls -ltr
total 0
drwxr-xr-x 2 root root 6 Apr 15 2020 home
drwxr-xr-x 2 root root 6 Apr 15 2020 boot
lrwxrwxrwx 1 root root 8 Jun 9 15:27 sbin -> usr/sbin
lrwxrwxrwx 1 root root 10 Jun 9 15:27 libx32 -> usr/libx32
lrwxrwxrwx 1 root root 9 Jun 9 15:27 lib64 -> usr/lib64
lrwxrwxrwx 1 root root 9 Jun 9 15:27 lib32 -> usr/lib32
lrwxrwxrwx 1 root root 7 Jun 9 15:27 lib -> usr/lib
lrwxrwxrwx 1 root root 7 Jun 9 15:27 bin -> usr/bin
drwxr-xr-x 1 root root 19 Jun 9 15:27 usr
drwxr-xr-x 2 root root 6 Jun 9 15:27 srv
drwxr-xr-x 2 root root 6 Jun 9 15:27 opt
drwxr-xr-x 2 root root 6 Jun 9 15:27 mnt
drwxr-xr-x 2 root root 6 Jun 9 15:27 media
drwxr-xr-x 1 root root 45 Jun 9 15:31 var
drwx------ 2 root root 37 Jun 9 15:31 root
dr-xr-xr-x 1172 root root 0 Nov 25 19:53 host
dr-xr-xr-x 13 root root 0 Nov 25 19:53 sys
drwxr-xr-x 1 root root 20 Nov 26 13:39 etc
dr-xr-xr-x 1172 root root 0 Nov 26 13:39 proc
drwxr-xr-x 1 root root 77 Nov 26 13:39 apps
drwxr-xr-x 16 root root 4020 Nov 26 13:39 dev
drwxr-xr-x 1 root root 43 Nov 26 13:39 run
drwxrwxrwt 1 root root 68 Nov 30 17:47 tmp
root@zabbix-unify:/#
-l use a long listing format 以长列表方式显示(详细信息方式)
-t sort by modification time 按修改时间排序(最新的在最前面)
-r reverse order while sorting (反序)
按标准时间格式, 显示时间, 便于 GREP 查找等操作
详细解释:
--time-style=TIME_STYLE time/date format with -l; see TIME_STYLE below
The TIME_STYLE argument can be full-iso, long-iso, iso, locale, or +FORMAT. FORMAT is interpreted like in date(1). If FORMAT is FORMAT1
FORMAT2, then FORMAT1 applies to non-recent files and FORMAT2 to recent files. TIME_STYLE prefixed with ‘posix-‘ takes effect only outside the POSIX locale. Also the TIME_STYLE environment variable sets the default style to use.
ls -al --time-style=long-iso