When I use [0-9]
pattern to search for all numbers in a file, whether to use or not use single/double quotes around the pattern produces different outputs.
$ cat numbers
this line has 3
this line has 4
this line has 2
this line has 8
this line has 1
$ grep [0-9] numbers
this line has 1
$ grep '[0-9]' numbers
this line has 3
this line has 4
this line has 2
this line has 8
this line has 1
What makes the difference between [0-9]
and '[0-9]'
? I did a similar test with [a-z]
and '[a-z]'
, but the results were the same unlike the previous example.
I tested it on my 16.04.7 LTS (Xenial Xerus) machine. It worked as expected when I did the same test on my Mac.
ls -l
. You likely have a file with a name matching that globbing pattern. – Kusalananda Jan 17 '21 at 07:40