look(1)

look1

Display lines beginning with a given string

Usage

look [-df] [-t termchar] string [file ...]

Overview

The look utility displays any lines in file which contain string as a prefix. As look performs a binary search, the lines in file must be sorted.

If file is not specified, the file /usr/share/dict/words is used, only alphanumeric characters are compared and the case of alphabetic characters is ignored.

The following options are available:

-d, --alphanum

Dictionary character set and order, i.e., only alphanumeric characters are compared.

-f, --ignore-case

Ignore the case of alphabetic characters.

-t, --terminate termchar

Specify a string termination character, i.e., only the characters in string up to and including the first occurrence of termchar are compared.

Environment

The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of the look utility. Their effect is described in environ(7).

Files

/usr/share/dict/words

the dictionary

Exit status

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.

Examples

Look for lines starting with ‘xylen’ in the file /usr/share/dict/words:

$ look xylen
xylene
xylenol
xylenyl

Same as above, but do not consider any characters in string beyond the first ‘e’. Note that -f is implicit since we are searching the default file /usr/share/dict/words:

$ look -t e xylen
Xyleborus
xylem
xylene
xylenol
xylenyl
xyletic

Compatibility

The original manual page stated that tabs and blank characters participated in comparisons when the -d option was specified. This was incorrect and the current man page matches the historic implementation.

The -a and --alternative flags are ignored for compatibility.

Releases

87 releases since FreeBSD 2.0.5-RELEASE; the text changed 47 times.

  1. 2.0.5–2.1.7.1
  2. 2.2.2
  3. 2.2.5–2.2.9
  4. 3.0–3.5.1
  5. 4.0–4.2
  6. 4.3
  7. 4.4–4.6.2
  8. 4.7–4.11
  9. 5.0–5.1
  10. 5.2–5.2.1
  11. 5.3–5.5
  12. 6.0–6.3
  13. 6.4
  14. 7.0
  15. 7.1
  16. 7.2
  17. 7.3
  18. 7.4
  19. 8.0
  20. 8.1
  21. 8.2
  22. 8.3
  23. 8.4
  24. 9.0
  25. 9.1
  26. 9.2
  27. 9.3
  28. 10.0
  29. 10.1
  30. 10.2
  31. 10.3
  32. 10.4
  33. 11.0
  34. 11.1
  35. 11.2
  36. 11.3
  37. 11.4
  38. 12.0
  39. 12.1
  40. 12.2
  41. 12.3
  42. 12.4
  43. 13.0–13.2
  44. 13.3–13.4
  45. 13.5
  46. 14.0–14.1
  47. 14.2–14.5
  48. 15.0–16.0

--alphanum since FreeBSD 11.0-RELEASE; --ignore-case since FreeBSD 11.0-RELEASE; --terminate since FreeBSD 11.0-RELEASE.

History

A look utility appeared in Version 7 AT&T UNIX.

Bugs

Lines are not compared according to the current locale's collating order. Input files must be sorted with LC_COLLATE set to ‘C’.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.