Bin*_*ong 0 bash shell terminal
在一次调用中获取所有隐藏和非隐藏目录(仅目录)的列表的最简单方法是什么?
显然我可以通过连接两个不同的命令来做到&&这一点,如下所示:
ls -d ./.*/ && ls -d ./*/
Run Code Online (Sandbox Code Playgroud)
但不应该有更好的方法吗?
编辑:我不希望当前目录包含在列表中。
另外,ls -d ./.*/ ./*/这是比我上面的更好的选择。
您bash不需要调用任何外部实用程序来列出所有目录(包括隐藏目录)。只需使用:
# make sure we match entries starting with dot and return empty when list is empty
shopt -s dotglob nullglob
# print all the directories including ones starting with dot
printf '%s\n' */
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1506 次 |
| 最近记录: |