shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [shell-script] grep e fgrep (-w, --word-regexp)


From: Tiago Barcellos Peczenyj
Subject: Re: [shell-script] grep e fgrep (-w, --word-regexp)
Date: Mon, 10 Apr 2006 10:43:23 -0300

-w, --word-regexp
       Select  only  those  lines  containing  matches  that form whole
       words.  The test is that the matching substring must  either  be
       at  the  beginning  of  the line, or preceded by a non-word con-
       stituent character.  Similarly, it must be either at the end  of
       the line or followed by a non-word constituent character.  Word-
       constituent characters are letters, digits, and the  underscore.

Ou seja, ele procura uma palavra exata. O que delimita uma palavra eh
qualquer caracter que não seja letra, numero ou underscore

$ cat teste
apolo10:$1$Pa7zKooy$wg/SdAW5Pveto7JZSUVej1:12641:0:99999:7:::
apolo105:$1$Pa7zKooy$wg/SdAW5Pveto7JZSUVej1:12641:0:99999:7:::
apolo10_:$1$i24lU7O.$z1uldsb4BsWadY3BMvP23.:12641:0:99999:7:::
apolo10@:$1$6aZHmYIw$x5TNCiAY8kEVCak0w6r2j0:12641:0:99999:7:::
apolo10 :$1$Pa7zKooy$wg/SdAW5Pveto7JZSUVej1:12641:0:99999:7:::
apolo10A:$1$Pa7zKooy$wg/SdAW5Pveto7JZSUVej1:12641:0:99999:7:::

$ grep -w apolo10 teste
apolo10:$1$Pa7zKooy$wg/SdAW5Pveto7JZSUVej1:12641:0:99999:7:::
apolo10@:$1$6aZHmYIw$x5TNCiAY8kEVCak0w6r2j0:12641:0:99999:7:::
apolo10 :$1$Pa7zKooy$wg/SdAW5Pveto7JZSUVej1:12641:0:99999:7:::

$ fgrep -w apolo10 teste
apolo10:$1$Pa7zKooy$wg/SdAW5Pveto7JZSUVej1:12641:0:99999:7:::

Agora eu não entendi a diferença nos resultados (grep e fgrep), ambos são
versão 2.5.1
Mas ele encontra o resultado!

On 4/10/06, Marcus Vinicius <address@hidden> wrote:
>
>
>   Se tiver outras linhas que contenham apolo10 mesmo que não seja a
> palavra inteira ele não retorna.
>
>   Mas não é exatamente essa a função do "-w" ?
>
>   Estranho.
>
>   Marcus Vinicius
>

--
Tiago B Peczenyj
Linux User #405772

# cd /pub
# more beer


[As partes desta mensagem que não continham texto foram removidas]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]