xref: /freebsd/usr.bin/look/look.1 (revision 315ee00f)
1.\" Copyright (c) 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"     @(#)look.1	8.1 (Berkeley) 6/14/93
29.\"
30.Dd December 29, 2020
31.Dt LOOK 1
32.Os
33.Sh NAME
34.Nm look
35.Nd display lines beginning with a given string
36.Sh SYNOPSIS
37.Nm
38.Op Fl df
39.Op Fl t Ar termchar
40.Ar string
41.Op Ar
42.Sh DESCRIPTION
43The
44.Nm
45utility displays any lines in
46.Ar file
47which contain
48.Ar string
49as a prefix.
50As
51.Nm
52performs a binary search, the lines in
53.Ar file
54must be sorted.
55.Pp
56If
57.Ar file
58is not specified, the file
59.Pa /usr/share/dict/words
60is used, only alphanumeric characters are compared and the case of
61alphabetic characters is ignored.
62.Pp
63The following options are available:
64.Bl -tag -width indent
65.It Fl d , -alphanum
66Dictionary character set and order, i.e., only alphanumeric characters
67are compared.
68.It Fl f , -ignore-case
69Ignore the case of alphabetic characters.
70.It Fl t , -terminate Ar termchar
71Specify a string termination character, i.e., only the characters
72in
73.Ar string
74up to and including the first occurrence of
75.Ar termchar
76are compared.
77.El
78.Sh ENVIRONMENT
79The
80.Ev LANG , LC_ALL
81and
82.Ev LC_CTYPE
83environment variables affect the execution of the
84.Nm
85utility.
86Their effect is described in
87.Xr environ 7 .
88.Sh FILES
89.Bl -tag -width /usr/share/dict/words -compact
90.It Pa /usr/share/dict/words
91the dictionary
92.El
93.Sh EXIT STATUS
94The
95.Nm
96utility exits 0 if one or more lines were found and displayed,
971 if no lines were found, and >1 if an error occurred.
98.Sh EXAMPLES
99Look for lines starting with
100.Ql xylene
101in the file
102.Pa /usr/share/dict/words :
103.Bd -literal -offset indent
104$ look xylen
105xylene
106xylenol
107xylenyl
108.Ed
109.Pp
110Same as above, but do not consider any characters in
111.Ar string
112beyond the first
113.Ql e .
114Note that
115.Fl f
116is implicit since we are searching the default file
117.Pa /usr/share/dict/words :
118.Bd -literal -offset indent
119$ look -t e xylen
120Xyleborus
121xylem
122xylene
123xylenol
124xylenyl
125xyletic
126.Ed
127.Sh COMPATIBILITY
128The original manual page stated that tabs and blank characters participated
129in comparisons when the
130.Fl d
131option was specified.
132This was incorrect and the current man page matches the historic
133implementation.
134.Pp
135The
136.Fl a
137and
138.Fl -alternative
139flags are ignored for compatibility.
140.Sh SEE ALSO
141.Xr grep 1 ,
142.Xr sort 1
143.Sh HISTORY
144A
145.Nm
146utility appeared in
147.At v7 .
148.Sh BUGS
149Lines are not compared according to the current locale's collating
150order.
151Input files must be sorted with
152.Ev LC_COLLATE
153set to
154.Ql C .
155