如何在Linux上找到当前目录的所有直接子目录? [英] How can I find all immediate sub-directories of the current directory on Linux?
本文介绍了如何在Linux上找到当前目录的所有直接子目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Linux上找到当前目录的所有直接子目录?
How can I find all immediate sub-directories of the current directory on Linux?
推荐答案
最简单的方法是通过编写 echo */
来利用shell的globing功能.
The simplest way is to exploit the shell globbing capabilities by writing echo */
.
如果您想使用 ls
,例如要应用格式/排序选项,请将其设置为 ls -d */
.
If you like to use ls
, e.g. to apply formatting/sorting options, make it ls -d */
.
说明:
- 斜杠确保只考虑目录,而不考虑文件.
- 选项
-d
:列出目录本身,而不是目录内容
- The slash ensures that only directories are considered, not files.
- Option
-d
: list directories themselves, not their contents
这篇关于如何在Linux上找到当前目录的所有直接子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文