linux ls 仅显示目录,在Linux中使用ls仅显示目录

我逐渐熟悉Linux(Debian 9)。 但是我设法使自己对ls命令手册感到困惑。 我对测试进行了以下简单设置:meouser:~/triv_dir$ ls -laR

.:

total 24

drwxr-xr-x 4 meouser meouser 4096 Mar 27 15:42 .

drwxr-xr-x 19 meouser meouser 4096 Mar 27 15:41 ..

drwxr-xr-x 4 meouser meouser 4096 Mar 27 15:55 a

drwxr-xr-x 2 meouser meouser 4096 Mar 27 15:42 b

-rw-r--r-- 1 meouser meouser 6 Mar 27 15:44 c

-rw-r--r-- 1 meouser meouser 6 Mar 27 15:44 d

./a:

total 24

drwxr-xr-x 4 meouser meouser 4096 Mar 27 15:55 .

drwxr-xr-x 4 meouser meouser 4096 Mar 27 15:42 ..

-rw-r--r-- 1 meouser meouser 4 Mar 27 15:50 aa

-rw-r--r-- 1 meouser meouser 4 Mar 27 15:50 ab

drwxr-xr-x 2 meouser meouser 4096 Mar 27 15:55 a_sub_1

drwxr-xr-x 2 meouser meouser 4096 Mar 27 15:55 a_sub_2

./a/a_sub_1:

total 12

drwxr-xr-x 2 meouser meouser 4096 Mar 27 15:55 .

drwxr-xr-x 4 meouser meouser 4096 Mar 27 15:55 ..

-rw-r--r-- 1 meouser meouser 4 Mar 27 15:55 aaa

./a/a_sub_2:

total 8

drwxr-xr-x 2 meouser meouser 4096 Mar 27 15:55 .

drwxr-xr-x 4 meouser meouser 4096 Mar 27 15:55 ..

./b:

total 16

drwxr-xr-x 2 meouser meouser 4096 Mar 27 15:42 .

drwxr-xr-x 4 meouser meouser 4096 Mar 27 15:42 ..

-rw-r--r-- 1 meouser meouser 4 Mar 27 15:50 ba

-rw-r--r-- 1 meouser meouser 4 Mar 27 15:50 bb

我想查看所有目录名称及其子目录,但看不到文件名。 也就是说,我想要像ls --insert-options-here这样的东西,以便输出是上面的这个子集:.:

total 24

drwxr-xr-x 4 meouser meouser 4096 Mar 27 15:42 .

drwxr-xr-x 19 meouser meouser 4096 Mar 27 15:41 ..

drwxr-xr-x 4 meouser meouser 4096 Mar 27 15:55 a

drwxr-xr-x 2 meouser meouser 4096 Mar 27 15:42 b

./a:

total 24

drwxr-xr-x 4 meouser meouser 4096 Mar 27 15:55 .

drwxr-xr-x 4 meouser meouser 4096 Mar 27 15:42 ..

drwxr-xr-x 2 meouser meouser 4096 Mar 27 15:55 a_sub_1

drwxr-xr-x 2 meouser meouser 4096 Mar 27 15:55 a_sub_2

根据ls手册,应通过ls -ldR实现。meouser:~/triv_dir$ man ls

-a, --all

do not ignore entries starting with .

-d, --directory

list directories themselves, not their contents

-l use a long listing format

-R, --recursive

list subdirectories recursively

但这是发生的事情:只有'.' 显示。meouser:~/triv_dir$ ls -ldR

drwxr-xr-x 4 meouser meouser 4096 Mar 27 15:42 .

我在手册中缺少什么?

我从https://stackoverflow.com/a/29277454/11199684注意到,这可以通过find . -maxdepth 2 -type d -print实现find . -maxdepth 2 -type d -print find . -maxdepth 2 -type d -print令人印象深刻,但与上面的ls输出相比,它提供的信息较少。 此外,我可能事先不知道正确的最大深度? 最重要的是,对于将来的需求,我实际上对从手册中自我介绍很有兴趣。 意见表示赞赏。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值