1. 程式人生 > >linux 之 查找目錄下有那些目錄的方法

linux 之 查找目錄下有那些目錄的方法

目錄下查找目錄

查找目錄下有那些目錄的方法
內容:
[root@localhost kang]# ll
total 16
-rw-r--r-- 1 root root    0 May  6 21:21 d.txt
drwxr-xr-x 2 root root 4096 May  6 21:14 kang
-rw-r--r-- 1 root root    0 May  5 18:55 kang.txt
drwxr-xr-x 2 root root 4096 May  5 23:40 nginx
-rw-r--r-- 1 root root    5 May  5 23:40 test.sh
-rw-r--r-- 1 root root   38 May  5 23:27 test.txt

方法一:通常方法
ls -l | grep ‘^d‘       #正則表達式^...以什麽為開頭 ,如^d.以d開頭

方法二:為目錄加標識
[root@localhost kang]# ls -F
d.txt  kang/  kang.txt  nginx/  test.sh  test.txt
[root@localhost kang]# ls -F | grep ‘/$‘      #以...結尾,如/$ 意思是以/結尾。
kang/
nginx/

方法三:find命令
[root@localhost kang]# find . -type d !  -name .
./nginx
./kang

linux 之 查找目錄下有那些目錄的方法