How to use wildcard with files which names start with '-'?
bash, macos, shell
Solution
Either use
ls -- *.png
or
ls ./*.png
The double dash is a common option in GNU tools to signify the end of options: any subsequent words starting with dash is a plain argument. `rm` works the same way.
Problem
There are some files which names start with '-', such as '-1.png', '-2.png'. I can't operate them with wildcard, because those names are regarded as options: ``` bash-3.2$ ls *.png ls: illegal option -- . usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...] bash-3.2$ rm *.png rm: illegal option -- 1 usage: rm [-f | -i] [-dPRrvW] file ... unlink file ``` How to solve this problem?