With regular expressions, you can perform much more complex searches than
the examples we've looked at so far by taking advantage of metacharacters.
One of these metacharacters is the .
(a period), which matches any
single character:
$ grep dev.hda /etc/fstab
/dev/hda3 / reiserfs noatime,ro 1 1
/dev/hda1 /boot reiserfs noauto,noatime,notail 1 2
/dev/hda2 swap swap sw 0 0
#/dev/hda4 /mnt/extra reiserfs noatime,rw 1 1
In this example, the literal text dev.hda
didn't appear on any
of the lines in /etc/fstab
. However, grep wasn't scanning them for
the literal dev.hda
string, but for the dev.hda
pattern. Remember that the .
will match any single
character. As you can see, the .
metacharacter is
functionally equivalent to how the ?
metacharacter works in
glob expansions.