look—displays lines beginning with a given string
look [-dfa] [-t termchar] string [file]
look displays any lines in a file that contain a string as a prefix. As look performs a binary search, the lines in the file must be sorted. If a file is not specified, the file /usr/dict/words is used, only alphanumeric characters are compared, and the case of alphabetic characters is ignored.
OPTIONS:
-d | Dictionary character set and order; i.e., only alphanumeric characters are compared. | -f | Ignores the case of alphabetic characters. | -a | Uses the alternate dictionary /usr/dict/web2. | -t | Specifies a string termination character; i.e., only the characters in string up to and including the first occurrence of the termination character are compared. |
The look utility exits 0 if one or more lines were found and displayed, 1 if no lines were found, and >1 if an error occurred.
Example A.34.
1 % look sunb
sunbeam
sunbeams
Sunbelt
sunbonnet
sunburn
sunburnt
2 % look karen sorted.datebook
3 % look Karen sorted.datebook
Karen Evich:284-758-2857:23 Edgecliff Place, Lincoln, NB
92086:7/25/53:85100
Karen Evich:284-758-2867:23 Edgecliff Place, Lincoln, NB
92743:11/3/35:58200
Karen Evich:284-758-2867:23 Edgecliff Place, Lincoln, NB
92743:11/3/35:58200
4 % look -f karen sorted.datebook
Karen Evich:284-758-2857:23 Edgecliff Place, Lincoln, NB
92086:7/25/53:85100
Karen Evich:284-758-2867:23 Edgecliff Place, Lincoln, NB
92743:11/3/35:58200
Karen Evich:284-758-2867:23 Edgecliff Place, Lincoln, NB
92743:11/3/35:58200
EXPLANATION
look displays all lines in /usr/dict/words that start with the string sunb, assuming /usr/dict/words is in the current directory. look cannot find a line that starts with karen in a file called sorted.datebook. (The file must be sorted or look will not find anything.) look displays all lines with lines starting with the string, Karen, in file, sorted.datebook. The -f option folds upper and lowercase in the search string (i.e., turns off casesensitivity).
|