我想只列出指定路径中的目录(ls没有这样的选项)。 另外,这可以用单行命令完成吗?


当前回答

下面是另一个显示链接目录的解决方案。 我稍微喜欢它,因为它是“正常”ls -l输出的子集:

ls -1d */ | rev | cut -c2- | rev | xargs ls -ld --color=always

其他回答

尝试使用ls -d */来列出当前目录中的目录

### If you need full path of dir and list selective dir with "name" of dir(or dir_prefix*):
find $(pwd) -maxdepth 1 -type d -name "SL*"

要只列出指定路径下的目录,只需键入

ls -l | grep drw

以下

find * -maxdepth 0 -type d

基本上过滤'*'的展开,即当前目录中的所有条目,通过类型d条件。

优点是,输出与ls -1 *相同,但只针对目录 条目不以点开头

这对我来说很管用:

ls -F | grep /

(但是,我正在切换到@nos提到的echo */)