The last metacharacters we will cover in detail here are the ^
and $
metacharacters, used to match the beginning and end of line,
respectively. By using a ^
at the beginning of your regex, you
can cause your pattern to be "anchored" to the start of the line. In the
following example, we use the ^#
regex to match any line beginning
with the #
character:
$ grep ^# /etc/fstab
# /etc/fstab: static file system information.
#