In the following examples, search is run.
This example searches for "fred" in /usr/dict/words - a dictionary list
of common words. It prints out lines that match with the match term
highlighted, as well as the surrounding two lines.
$ search fred /usr/dict/words
Alfonso
alfonso
Alfred
Alfredo
alfresco
alga
-----
mane
maneuver
Manfred
manganese
mange
-----
wile
Wiley
Wilfred
wilful
Wilhelm
-----
wingspan
wingtip
Winifred
wink
winkle
The following example shows how search helps looking through code. Here
it finds "while" in itself. "-n" has printed line numbers.
$ search -n while search
139:
140:$word = shift || usage(1);
141:while ($file = shift) {
142: push(@Files,$file)
143:}
-----
152:
153: $linenum = 0;
154: while ($line = ) {
155: search_line($line);
156: }
-----
159:} else {
160: # --- Search STDIN ---
161: while ($line = ) {
162: search_line($line);
163: }
The following demonstrates search using regular expressions,
$ search '^anchor$' /usr/dict/words
ancestral
ancestry
anchor
anchorage
anchorite