look - Unix, Linux Command


Advertisements


NAME

look - display lines beginning with a given string.

SYNOPSIS

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

    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 com-pared compared pared and the case of alphabetic characters is ignored. 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.

    Options

    Tag Description
    -a, --alternative Use the alternative dictionary file.
    -d, --alphanum Use normal dictionary character set and order, i.e. only blanks and alphanumeric characters are compared. This is on by default if no file is specified.
    -f, --ignore-case Ignore the case of alphabetic characters. This is on by default if no file is specified.
    -t, --terminate character Specify a string termination character, i.e. only the characters in string up to and including the first occurrence of character are compared.
    -V, --version Display version information and exit.
    -h, --help Display help text and exit.

    EXAMPLES

    Example-1:

    Check spelling using look command:

    For example, if you are not sure whether ‘exclaimation’ or ‘exclamation’ is the correct spelling, you can use look command with first few characters of the word.

    $ look excla

    output:

    exclaim
    exclaimed
    exclaiming
    exclaims
    exclamation
    exclamation's
    exclamations
    exclamatory
    
    This displays the word that starts with the given prefix from file /usr/share/dict/words.
    

    Example-2:

    To Check spelling for a word from user defined file:

    When you want to know the spelling of a word which has the prefix ‘excl’.

    $ look excl myfile

    output:

    exclaimed
    exclamation
    
    This displays the word that starts with the given prefix from file myfile.
    

    Example-3:

    Ignore case while searching for spelling of word:

    When you want to know the spelling of a word which has the prefix ‘excl’.

    $ look excl myfile

    output:

     exclaimed
     exclamation
     EXCLAMATORY
     
    This displays the word that starts with the given prefix from file myfile by ignoring the case.


    Advertisements