ls -d */
runs fine in all other directories that I tried, but in one specifically, I get this:
ls: invalid option -- '/'
Try 'ls --help' for more information.
I pasted the command in the terminal, so, it's exactly the same in both cases.
ls -d */
runs fine in all other directories that I tried, but in one specifically, I get this:
ls: invalid option -- '/'
Try 'ls --help' for more information.
I pasted the command in the terminal, so, it's exactly the same in both cases.
You appear to have a directory named -
, which ls
is trying to parse as a marking series of options (or switches):
$ mkdir -- -
$ ls -d */
ls: unknown option -- /
$ -ls -d -- */
-/
Many core tools take a special switch, --
, which means "No more switches; anything further is a normal argument".
Be wary of wildcards' use:
$ touch -- foo -i
$ ls
-i foo
$ ls *
2251799814054385 foo
Just imagine the chaos that might ensue if you were using rm
and there were a file called -fr
in your current working directory.
ls -ld [a-z]*/
or something similar maybe – francois P Feb 10 '20 at 17:26