ls invalid option '2'
You probably have some badly-named file in your folder which expands into -2...vcf
or something similar. You can run ls in this form: ls -- *.vcf
to get around it.
Explanation:
BASH performs wildcard expansion before running ls so there is probably something like ls -2...vcf blabla01.vcf blabla02.vcf
being invoked. By adding two dashes you tell the ls where the parameters end so it treats the -2...vcf
as a filename argument.
Related videos on Youtube
nak3c
Updated on September 18, 2022Comments
-
nak3c almost 2 years
I have the following files (among others) in a directory. I’m running Ubuntu 16.04.
484 May 8 21:50 NA19239.vcf 484 May 9 08:50 HG01583.vcf 484 May 9 08:51 HG01595.vcf 0 May 9 15:11 HG00268-WGS-cordSorted.bam.vcf 0 May 9 15:11 HG00096-WGS-cordSorted.bam.vcf 0 May 9 15:11 HG00419-WGS-cordSorted.bam.vcf
if I try
ls *.vcf
I get
ls: invalid option -- '2' Try 'ls --help' for more information.
I do not get the error for other file extensions in the directory. I do not get the error for .vcf files when I run the command in other directories. What is causing this error? I have not tried anything except searching for this error. Thanks.
-
Felipe about 6 yearsIs there a way to use the
--
and also output as a single column with-1
? because it seems that I can't use both together -
Fiisch about 6 yearsYou are probably just adding
-1
to the end of the command. That will not work because-1
is an option. the--
basically says "no more options after this point". Move the option to the beginning of the command and it should be fine:ls -1 -- *xml
.