如何仅列出点文件和点文件夹名称(不包含其中的内容)

Joe*_*Joe 3 linux shell ls

我想只列出隐藏的文件和文件夹(以dot开头).当我使用命令

ls .??*
Run Code Online (Sandbox Code Playgroud)

我得到了输出

.gitignore

.git:
COMMIT_EDITMSG FETCH_HEAD     HEAD           ORIG_HEAD      branches       config         description    hooks          index          info           logs           objects        packed-refs    refs
Run Code Online (Sandbox Code Playgroud)

我不想要文件夹中的内容.相反,我正在寻找仅列出文件夹的输出

.gitignore
.git [different color for the folders, like the normal ls]
Run Code Online (Sandbox Code Playgroud)

Ken*_*ent 9

尝试:

ls -d .*
Run Code Online (Sandbox Code Playgroud)

仅供参考

   -d, --directory
          list directories themselves, not their contents
Run Code Online (Sandbox Code Playgroud)

如果你的ls不是其他命令的别名,则上面的输出ls -d .*将在同一行输出文件/目录.如果你想让它们各自独立:

ls -d1 .*
Run Code Online (Sandbox Code Playgroud)

如果你想要彩色输出:

ls -d1 --color=auto .*
Run Code Online (Sandbox Code Playgroud)