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

标签 linux shell ls

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

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]

最佳答案

尝试:

ls -d .*

仅供引用

   -d, --directory
          list directories themselves, not their contents

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

ls -d1 .*

如果你想要彩色输出:

ls -d1 --color=auto .*

关于linux - 如何仅列出点文件和点文件夹名称(不包含其中的内容),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22408455/

相关文章:

shell - 如果未设置,则从控制台读取 Makefile 变量

c - 如何在嵌入式Linux中配置IP地址?

linux - 用于重命名一堆文件夹的 Bash 脚本

java - 在Java中将 "dir"的结果输出到控制台

c - 如何使用 'ls' cmd 仅打印目录中的隐藏文件?

检查 Stackable 文件系统是否以编程方式安装

linux - nasm array1.o : file not recognized: File format not recognized on Linux 32

目录名称中的 bash 空格使用 find 导致 ls 中的换行符

linux - 不要将 "+"添加到 linux 内核版本

r - 在 R 中安装 tm 包