I just can't ever work out whether I am supposed to be using globbing or regex with bash. My book on bash shell scripting is so confusing specifically because it doesn't clear this topic up and I never end up getting my understanding right. Let me give an example, it states the following:... The . (dot) character means "any single character." Thus, a.c matches all of abc, aac, aqc, and so on.
Ok great, I'm thinking he's wrong because this is regex, but the first thing I do, is test it anyway:
$ touch abc aac aqc
$ ls
aac abc aqc
$ ls a.c
ls: cannot access 'a.c': No such file or directory
I then go and google globbing, and come across this post called "globbing tutorial", and I'm thinking, right this is the one.
https://linuxhint.com/bash_globbing_tutorial/
I'm almost immediately thinking it's all wrong because half his "globbing" is done via grep, which uses BRE which isn't globbing. For example he states:
"$ is used to define the ending character"
This is wrong, because that's the regex meaning, and it's not globbing. So I test it:
$ ls
aac abc aqc
$ ls c$
ls: cannot access 'c$': No such file or directory
So his number 1 hit link on google is wrong as well. It's like there's no post that clarifies this topic either in books or online, so I need some help to define the difference between regex and globbing, with some absolute certainty.
Caret – (^)
section. IMHO you'd be better off reading the bash manual's Pattern Matching – steeldriver Dec 15 '22 at 18:40