globs vs regexps
Posted Aug 5, 2004 5:31 UTC (Thu) by
rfunk (subscriber, #4054)
Parent article:
Bash 3.0 released
The "failglob" option will probably be of interest to many
users. When set, this option will cause an error when a regular
expression fails to match any files
Filename globs are not regular expressions.
Filename globs are those expressions where ? matches a single character,
* matches any number of characters, and the beginning and end are always
anchored (e.g. a*d matches abcd but not qabcdz).
Regular expressions have a precise meaning I don't remember at the
moment, but commonly refer to expressions where a period matches a single
character, a * modifies a previous bit of the expression to match
any number of that bit, and beginning and end achors must be explicitly
specified if they are desired. (a.*d matches both abcd and qabcdz.)
The single-star glob "*" is equivalent to the four-character regular
expression "^.*$".
Confusion between these two systems trips up a lot of people, so it's
important not to refer to one when you mean the other.
(
Log in to post comments)