Wildcard argument to cygwin utility

5

Command

ls "myfolder"

does its job, listing csv files inside the folder. Yet

ls "myfolder/*.csv" -> No such file or directory

because

ls "myfolder/*" -> No such file or directory

and

ls "myfolder\*" -> No such file or directory

Val

Posted 2014-06-16T14:20:07.813

Reputation: 1

3The double quotes make it look for a file that literally has an asterisk in its name; don't use them. That shell expansion is how ls is able to list filenames that match a wildcard in the first place. – Jason C – 2014-06-16T14:22:54.553

Answers

6

Try using your ls command without the double quotes, like:

ls myfolder/*.csv

Because you put the double quotes around the wildcard (asterisk), the shell doesn't do any expansion and will try to find a file named *.csv.

mtak@frisbee:~$ ls tst/*.txt
tst/bar.txt  tst/bla.txt  tst/foo.txt
mtak@frisbee:~$ ls "tst/*.txt"
ls: cannot access tst/*.txt: No such file or directory

mtak

Posted 2014-06-16T14:20:07.813

Reputation: 11 805

1+1 Adding to this; the wildcard expansion is done by the shell and the expanded list of filenames are passed to ls -- its not ls itself doing the wildcard matching. The double quotes prevent the shell from doing it. ls just takes literal filenames and doesn't itself know about wildcards. The double quotes prevent the shell from doing this and the asterisk is passed unaltered. – Jason C – 2014-06-16T14:24:58.810

0

Clearly you will need some kind of quoting if there are spaces in the path. The solution is to move the wildcards outside the quotes:

ls "myfolder/"*.csv

and especially

ls "my folder/"*.csv

Fortunately, Windows doesn't screw this up.

Thanks @vonbrand

Bob Stein

Posted 2014-06-16T14:20:07.813

Reputation: 985