简体   繁体   English

命令列出Linux目录中的所有文件夹和子文件夹

[英]command to list all the folders and sub-folders in a directory in linux

I would like to check all the folders and sub-folders in a directory. 我想检查目录中的所有文件夹和子文件夹。

ls -R works fine, but it lists all the files in each folder and sub-folder. ls -R可以正常工作,但是它列出了每个文件夹和子文件夹中的所有文件。 As a result I can't see what I want to check unless ls -R |less . 结果,除非ls -R |less否则我看不到要检查的内容。

ls -R | less ls -R | less is also not a good choice because I have thousands and thousands of files in each sub-folder. ls -R | less是一个好选择,因为每个子文件夹中都有成千上万个文件。

Install tree package. 安装tree包。 You can easily change max display depth of directory with -L . 您可以使用-L轻松更改目录的最大显示深度。

For example: 例如:

$ tree -L 1 /
/
├── bin -> usr/bin
├── boot
├── dev
├── etc
├── home
├── lib -> usr/lib
├── lib64 -> usr/lib
├── lost+found
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin -> usr/bin
├── srv
├── sys
├── tmp
├── usr
└── var

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM