Sample Header Ad - 728x90

Glob and regex matching

2 votes
1 answer
6950 views
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 *.
Asked by Vera (1363 rep)
Jan 29, 2023, 08:55 PM
Last activity: May 15, 2025, 12:39 PM