bash – Glob and regex matching
Bash
has two types of pattern matching, Glob
and Regex
. The general rule of usage seems to be that 1) the simpler glob
is done to search filenames 2) regex
is used for searching text.
Glob
uses the metacharacters at the front, regex
uses the metacharacters at the end of the pattern
.
Glob Regex
?(pattern) (pattern)?
*(pattern) (pattern)*
+(pattern) (pattern)+
I therefore have difficulty understanding how file matching with wildcards (e.g. *.sh
). Are wildcards something different than glob patterns? From what I see, the search pattern *.sh
does not include a metacharacter to match any character after *
.
Read more here: Source link