Let me introduce a simple UNIX/Linux command which is very useful but not that popular.
Its called 'look'. And as the name suggests, this command displays lines beginning with a given string.
look string <file>
The look utility displays any lines in 'file' which contain 'string' as a prefix. This can be a simple alternative of using
$ grep "^string" <file>
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.
And I feel this lookup of dictionary words from 'usr/share/dict/words' can be a very common use of this utility.
$ look advis
In order to ignore the case of alphabetic characters you can use its -f option. (similar to grep -i)
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.
- Generate random word in UNIX/Linux from dict/words
- UNIX - grep and print control characters from file
- Perform exact match with UNIX grep command
- UNIX grep command - print only matched string and not line
- Highlight match with color in grep