Lendo por alto, acho que apenas um grep -w resolveria isso, não acha?

Do man do grep:

-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.



Marlon Vagner Reck wrote:
>
> Amigos
>
> Comprei 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 
> echo
> mostra 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
>
>  

Responder a