grep
.
tr
or
sed
.
more
and less
.
sort
and
uniq
a
matches the character "a".
ab
matches the sequence "ab"
a|b
matches either the character "a" or the
character "b".
(a|b)(a|b)
matches any length-two sequence of
"a"s and "b"s.
(a+b)*
matches any sequence of "a"s and "b"s.
[abc]
is shorthand for a|b|c
(assuming,
of course, that we could write the latter.
[a-h]
is shorthand for a|b|c|d|e|f|g|h
.
^
as the first element of the set. For example,
[^a-zA-Z]
matches any character that isn't a letter.
^
and at the end of the line with $
(alternately, you can think of ^
as a special character
that matches the beginning of the line and $
as a special
character that appears at the end of the line).
*
(meaning zero or more repetition), the plus
+
(meaning one or more repetitions).
\
). You don't need to quote things you
put in sets.
\(
and
\)
.
\#
, where #
is a
digit between 0 and 9, representing the number of the parenthesized
subexpression.
% man 5 regexp
sed
and grep
.
grep
("general regular-expression pattern matching", or
some such) permits you to extract lines from a file that match a
particular pattern.
sed
("stream editor") allows you to modify lines
based on a regular expression.
grep
grep
's primary purpose is information extraction --
it's used to extract appropriate lines from a file.
-E
flag, or egrep
on some
Unix systems.
-i
flag for case-insensitive matching.
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Fri Nov 21 07:58:52 1997.
This page generated on Fri Nov 21 08:22:33 1997 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu