xref: /freebsd/usr.bin/look/look.1 (revision f552d7ad)
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.Dd December 29, 2020
29.Dt LOOK 1
30.Os
31.Sh NAME
32.Nm look
33.Nd display lines beginning with a given string
34.Sh SYNOPSIS
35.Nm
36.Op Fl df
37.Op Fl t Ar termchar
38.Ar string
39.Op Ar
40.Sh DESCRIPTION
41The
42.Nm
43utility displays any lines in
44.Ar file
45which contain
46.Ar string
47as a prefix.
48As
49.Nm
50performs a binary search, the lines in
51.Ar file
52must be sorted.
53.Pp
54If
55.Ar file
56is not specified, the file
57.Pa /usr/share/dict/words
58is used, only alphanumeric characters are compared and the case of
59alphabetic characters is ignored.
60.Pp
61The following options are available:
62.Bl -tag -width indent
63.It Fl d , -alphanum
64Dictionary character set and order, i.e., only alphanumeric characters
65are compared.
66.It Fl f , -ignore-case
67Ignore the case of alphabetic characters.
68.It Fl t , -terminate Ar termchar
69Specify a string termination character, i.e., only the characters
70in
71.Ar string
72up to and including the first occurrence of
73.Ar termchar
74are compared.
75.El
76.Sh ENVIRONMENT
77The
78.Ev LANG , LC_ALL
79and
80.Ev LC_CTYPE
81environment variables affect the execution of the
82.Nm
83utility.
84Their effect is described in
85.Xr environ 7 .
86.Sh FILES
87.Bl -tag -width /usr/share/dict/words -compact
88.It Pa /usr/share/dict/words
89the dictionary
90.El
91.Sh EXIT STATUS
92The
93.Nm
94utility exits 0 if one or more lines were found and displayed,
951 if no lines were found, and >1 if an error occurred.
96.Sh EXAMPLES
97Look for lines starting with
98.Ql xylen
99in the file
100.Pa /usr/share/dict/words :
101.Bd -literal -offset indent
102$ look xylen
103xylene
104xylenol
105xylenyl
106.Ed
107.Pp
108Same as above, but do not consider any characters in
109.Ar string
110beyond the first
111.Ql e .
112Note that
113.Fl f
114is implicit since we are searching the default file
115.Pa /usr/share/dict/words :
116.Bd -literal -offset indent
117$ look -t e xylen
118Xyleborus
119xylem
120xylene
121xylenol
122xylenyl
123xyletic
124.Ed
125.Sh COMPATIBILITY
126The original manual page stated that tabs and blank characters participated
127in comparisons when the
128.Fl d
129option was specified.
130This was incorrect and the current man page matches the historic
131implementation.
132.Pp
133The
134.Fl a
135and
136.Fl -alternative
137flags are ignored for compatibility.
138.Sh SEE ALSO
139.Xr grep 1 ,
140.Xr sort 1
141.Sh HISTORY
142A
143.Nm
144utility appeared in
145.At v7 .
146.Sh BUGS
147Lines are not compared according to the current locale's collating
148order.
149Input files must be sorted with
150.Ev LC_COLLATE
151set to
152.Ql C .
153