Last Updated : 06 Oct, 2024
The look command in Linux is used to display lines that begin with a specified string. It is especially useful for searching through large files or lists, as it helps you locate entries efficiently. By default, the look command performs case-insensitive matches and searches for exact prefixes. The look command in Linux shows the lines beginning with a given string. This command also uses binary search if the file is sorted. If the file is not specified, the file "/usr/share/dict/words" is used. Then only the alphanumeric characters are compared and the case of alphabetic characters is ignored.
Syntaxlook [OPTION]... STRING [FILE]
where,
Option
Description
-f, --ignore-case
Ignore case distinctions
-d, --alphanum
Search using only alphanumeric characters
-t, --terminate
Limit search by specifying a termination character
--version
Display version information
1. -[string]:This option is used to search for the given string in a specified file.
Example:
look "include" Assignment.c2. -f:
This option is used to ignore case of alphabetic character.
Example:
look -f ab words3. -t:
This option is used to specify a string termination character, i.e., only the characters in string up to and including the first occurrence of character are compared.
Example:
look -t b abu words4. -d:
This option is used to compare only alphanumeric characters.
Example:
look -d ab words5. -h:
This option is used to show the help message and exit.
Example:
look -h6. -V:
This option is used to show the version information and exit.
Example:
look -VConclusion
The look command is a powerful tool for quickly searching through large files or lists for lines that begin with a specified string. It provides options to make searches case-insensitive, limit the search scope, or focus on alphanumeric characters. Whether you're working with dictionaries or custom files, look can be a valuable utility in your Linux command-line toolkit.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4