在bash中,我尝试了
ls [a-z]*
并希望列出所有文件名以小写字母开头的文件。但是,为什么还会显示名称以大写字母开头的文件?
>ls [a-z]*
D e
>
如果需要,bash版本:
bash --version GNU bash,版本4.1.5(1)-发行版(i486-pc-linux-gnu)版权所有(C)2009自由软件基金会,公司。许可证GPLv3 +:GNU GPL版本3或更高版本http:// gnu .org / licenses / gpl.html
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
它不是regexp,而是引起混乱的地方。它使用的是一个名为“ globbing”的系统-请参阅:
$ man 7 glob
代替[az],您需要这样使用[[:lower:]]:
$ ls -d [[:lower:]]*
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句