dg
dog
doog
dogg
dogggg
doooggg
the dog
the dogs
dog dog
At your unix prompt, type
% grep 'dog'
Observe that nothing happens. This is because grep is waiting for
the other half of its input. Type ctrl-c. Observe that you get your
prompt back.
At your unix prompt, type
% grep 'dog' grepfile
Observe what happens. Before proceeding, some notes
on grep and regular expressions:
It's a good idea to enclose your regular expression in
single quotes ('), because otherwise the shell will try to
interpret some of the special characters, notably *.
Some of the regular expression syntax you learned about
doesn't work for normal grep. For instance, grep
doesn't have + or ? as part of its regular expression syntax. To
use those, try ``extended grep'' or egrep.
Now work out a regular expression to use that will make grep
return only the line containing just the word dog. Test it by typing
% grep 'xxx' grepfile
with your regular expression instead of 'xxx'
hint: Remember those anchors ^ and $
Now work out a regular expression for egrep that will make
grep return only the lines "dog" and "doog".