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

猜你喜欢

转载自blog.51cto.com/12965094/2113331
今日推荐