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


当前回答

### 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*"

其他回答

Du -d1可能是最短的选项。(只要您不需要将输入管道输送到另一个命令即可。)

### 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*"

我发现在我面前有很多好的答案。但我想添加一个命令,我们已经使用它几次,所以很容易列出所有的目录较少的努力:

cd

(注意:cd后面有空格),按tab键两次,它将只列出当前工作目录下的所有目录。希望这是容易使用的。如果有任何问题请让我知道。谢谢。

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

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

试试这个:

find . -maxdepth 1 -type d