我有一个文件夹 ~/anna,其中包含文件 ~/anna/b
当我输入 ls ~/a* 我得到 b。
如何检索 ~/anna ?
重现场景的脚本:
cd ~/
mkdir anna
touch anna/b
ls ~/a*
预期结果:安娜
实际结果:b
谢谢!
最佳答案
要获得有关 ls
的帮助,只需请求它:
ls --help
您将获得 ls
命令的有用选项列表,其中之一:
-d
,--directory
list directory entries instead of contents, and do not dereference symbolic links
所以解决方案(如评论中所述)是:
ls -d ~/a*
关于linux - Bash 列出与模式匹配的目录,而不是它们的子目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32221536/