If we wanted to match a character a bit more specifically than
.
, we could use [
and ]
(square
brackets) to specify a subset of characters that should be matched:
$ grep dev.hda[12] /etc/fstab
/dev/hda1 /boot reiserfs noauto,noatime,notail 1 2
/dev/hda2 swap swap sw 0 0
As you can see, this particular syntactical feature works identically to
the []
in "glob" filename expansions. Again, this is one of the
tricky things about learning regular expressions -- the syntax is
similar but not identical to "glob" filename expansion syntax, which
often makes regexes a bit confusing to learn.