look(1) General Commands Manual look(1)NAME
look - Finds lines in a sorted list
SYNOPSIS
look [-df] [-tcharacter] string [file]
The look command prints all lines in a sorted file that begin with string.
OPTIONS
Uses dictionary order; only letters, digits, tabs, and spaces are used in comparisons. Searches without regard to case; treats uppercase
and lowercase as equivalent. Ignores character and characters following it in the search string. If you specify look -tC ABCDE, the
string ABCDE would become (in effect) AB, with CDE being ignored. This option is primarily for shell scripts, in which more than one
string is being processed.
DESCRIPTION
If no file is specified, look searches in the system word list /usr/share/dict/words, with the options -df assumed by default.
The look command uses binary search.
The -d and -f options affect comparisons as in sort.
NOTES
In order to use the -f option, you must first sort file with the sort -f command; otherwise, look displays only lowercase items.
If you do not specify -f, but specify a file (such as /usr/share/dict/words) that has been sorted with sort -f, look may not produce any
output.
EXAMPLES
To search a sorted file called sortfile for all lines that begin with the string as, enter: look as sortfile To search the system word list
for all words beginning with smi, enter: look smi
This might result in: smile smirk smith smithereens Smithfield Smithson smithy smitten
FILES
System word list.
SEE ALSO
Commands: grep(1), sort(1), spell(1)look(1)
Check Out this Related Man Page
LOOK(1) BSD General Commands Manual LOOK(1)NAME
look -- display lines beginning with a given string
SYNOPSIS
look [-bdf] [-t termchar] string [file ...]
DESCRIPTION
The look utility displays any lines in file which contain string as a prefix.
If file is not specified, the file /usr/share/dict/words is used, only alphanumeric characters are compared and the case of alphabetic char-
acters is ignored.
The following options are available:
-b Use a binary search on the given word list. If you are ignoring case with -f or ignoring non-alphanumeric characters with -d, the
file must be sorted in the same way. Please note that these options are the default if no filename is given. See sort(1) for more
information on sorting files.
-d Dictionary character set and order, i.e., only alphanumeric characters are compared.
-f Ignore the case of alphabetic characters.
-t 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.
COMPATIBILITY
The original manual page stated that tabs and blank characters participated in comparisons when the -d option was specified. This was incor-
rect and the current man page matches the historic implementation.
look uses a linear search by default instead of a binary search, which is what most other implementations use by default.
SEE ALSO grep(1), sort(1)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'.
BSD July 17, 2004 BSD
Man Page
15 More Discussions You Might Find Interesting
1. Post Here to Contact Site Administrators and Moderators
It seems like the search engine does not allow searches for words with
less than four characters.
What if the search is for 'sed' or 'awk'? (16 Replies)
i have a file call text and i what the user to enter any word he/she wants to replace with any word
i current have
cat text
echo "Please enter the word to be amended:"
read old
echo "Please enter a new word:"
read new
sed "s/$old/$new/g" $1 > text
echo "press ENTER to continue"... (14 Replies)
Dear experts,
Ive been trying to figure this out for a while, but i cant. Please help.
I have a file, with approx 1 million lines. The contents are separated with "----------". Please see example below
So my problem is, i need to find all texts that have the keyword "GAA", but i need... (14 Replies)
Hi,
I am writing a shell (after 6-7 months)that has to receive text from another shell, check if the first line in the text has a key word and then execute different shell.I could come up with the below program structure, please suggest me if there is a better way to do it or please help me with... (14 Replies)
ok, apparently this is a very difficult question to answer based on my searches on google that came up fruitless.
what i want to do is grep through a file for words that match a specified string.
but the thing is, i keep getting all words in the file that have the string in them.
say for... (27 Replies)
Hi
Im looking for a way, hopefully a one-liner to sort words in a line
e.g
"these are the words in a line"
to
"a are in line the these words"
Thanks! (15 Replies)
I have, a file wich list file on server ftp and i want to sort the file text as the command "ls -t"
i.e
drwxr-x--- 2 ftp_mont System 0 Sep 30 09:16 .
drwxr-x--- 2 ftp_mont System 0 Jul 15 2009 ..
-rwxr-x--- 1 ftp_mont System 343998791 Sep 01 09:20 manif... (14 Replies)
Hi All,
I need to search in a csv file as mentioend in the Appendix A for a exact word lets "TEST".
But using teh below command iam getting TEST1234, TEST12 and otehr entries as well.
the problem is i check this condition to check to add a record to a table by making sure it does not... (16 Replies)
Hi all,
I am trying to grep a .txt file for a word. When I hit enter, it returns back to $
The file is 4155402 in size and is named in this way:
*_eveningtimes_done_log.txt
I use this command, being in the same directory as the file:
grep -i "invalid" *_eveningtimes_done_log.txt
... (16 Replies)
Hi,
I am trying to remove spaces from the beginning of a string (which i am using in my shell script). For ex - my string looks like this -
" no rows selected"
and i want the string to look like this -
"no rows selected"
How can i achieve this?
Thanks! (18 Replies)
Hi, all:
I would like to search all files under "./" and its subfolders recursively to find out
those files contain both word "A" and word "B", and list the filenames finally.
How to realize that?
Cheers
JIA (18 Replies)
Hi,
I would like to monitor the log, and if the user is appearing for more than threshold, then it should alert me.
-- log --
conn=867199 op=17 msgId=21 - MOD dn="uid=
+acp100,ou=internal,ou=People1,dc=abc,dc=xxx,dc=com"
what i want is that script should pull user out each user and... (14 Replies)
I have lines like:
table10 table_name_10 table10 table_name_10
table20 table_name_20 table20 table_name_20
table30 table_name_30 table30 table_name_30
I want to change the second "table_names" in all lines to test_table_name. Required output would be:
table10 table_name_10 table10... (19 Replies)
Hi,
I wanted to grep string "ERROR" and "WORNING" after last occurrence of String "Starting" only and wanted to display two lines after searched ERROR and WORNING string and one line before. I have following cronjob log file "errorlog" file and I have written the code for same in Unix as below... (17 Replies)
Can anyone explain what each line of the code does and how it works? I have no experience with python so I am not sure how the arrays and such work. I found this code while looking through the forums.
f = open("exams","r")
l = f.readline()
while l:
l = l.split(" ")
values = l
... (22 Replies)