|
From: | Bruno Gunter |
Subject: | Re: [shell-script] Dúvida grep e váriavel |
Date: | Sun, 13 Jul 2008 21:01:22 -0300 |
User-agent: | Thunderbird 2.0.0.14 (X11/20080501) |
Lendo por alto, acho que apenas um grep -w resolveria isso, não acha? Do man do grep: -w, --word-regexpSelect 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.
Marlon Vagner Reck wrote:
AmigosComprei o livro "Shell script profissional " do Aurélio ( muito bom por sinal)e me deparei com a seguinte linha: echo $2 | grep -qs $1 && echo "$1 está contida em $2"que pesquisa dentro de uma palavra a existência de outra, exemplo ana dentro de banana. Só que eu não consegui entender de o funcionamento dela, o echomostra a váriavel 2 digamos "banana" e joga no sub-shell para que o grep pesquise a váriavel 1 digamos "ana" dentro da palavra "banana", qual a mecânica da coisa a lógica? Desculpem a mensagem repetida, a outra não tinha assunto. Obrigado a todos Marlon
[Prev in Thread] | Current Thread | [Next in Thread] |