我想只列出隐藏的文件和文件夹(以dot开头)。当我使用命令
ls .??*
我得到了输出
.gitignore
.git:
COMMIT_EDITMSG FETCH_HEAD HEAD ORIG_HEAD branches config description hooks index info logs objects packed-refs refs
我不想要文件夹中的内容。相反,我正在寻找仅列出文件夹的输出
.gitignore
.git [different color for the folders, like the normal ls]
答案 0 :(得分:8)
尝试:
ls -d .*
FYI
-d, --directory
list directories themselves, not their contents
如果你的ls不是其他命令的别名,则上面ls -d .*
的输出将在同一行输出文件/目录。如果你想让它们各自独立:
ls -d1 .*
如果你想要彩色输出:
ls -d1 --color=auto .*
答案 1 :(得分:2)
ls -d .??*
-d
开关使得ls处理目录参数就像文件参数一样,并且不会列出其内容,而是显示通常的输出(手册摘录如下,感谢@fedorqui):
列出目录条目而不是内容,并且不要取消引用符号链接
它与-l
和其他人很好地结合,并且在没有任何其他开关的情况下,默认为ls
的通常多列视图。