我可以使用 ls -R 显示最多 2 个文件夹深度吗?

Agg*_*tis 12 directory ls

我有一个看起来像这样的文件夹树

main/                             
main/34532-23423632-2354/what-i-want/sth/other/blah-blah            
main/54634-56345634-3422/what-i-want/sth/
....
main/54356-34225675-2345/what-i-want/
Run Code Online (Sandbox Code Playgroud)

我希望它将树显示到我想要的文件夹中。因为文件夹………………………………………………………………………………

我只想看看每个名为 xxxx-xxxxxxxxx-xxxxx 的文件夹里面有什么。

有什么办法吗?

Tak*_*kat 12

使用通配符进行搜索,例如

ls /main/*/*/
Run Code Online (Sandbox Code Playgroud)

这将列出搜索深度为 2 的列表。用户可以使用更多通配符进行更深入的搜索。


vin*_*ser 10

如果只想显示文件名和目录名的列表,tree命令非常方便。

这不是默认安装的,你必须安装这个:

sudo apt-get install tree
Run Code Online (Sandbox Code Playgroud)

然后,您可以使用以下命令查看树结构:

tree -L 2 main/
Run Code Online (Sandbox Code Playgroud)

选项-L:将设置目录深度编号。

示例截图:

在此处输入图片说明