Como listar linhas semelhantes?

0

Os delimitadores podem ser: ""; "_"

ENTRADA:

foo#foo_ehh113#The password of user 111 will expire within the next seven d
foo#foo_ehh204#The password of user 111 will expire within the next seven d
sadf#sadf this is a sample_text
foo#foo_ehh204#The password of user 222 will expire within the next seven da
foo - moreeee test
foo#foo_ehh113#The password of user 222 will expire within the next seven da
foo#foo_ehh113#The password of user 333 will expire within the next seven day
ldr#ldr_another sample text
foo#foo_ehh204#The password of user 333 will expire within the next seven day

OUTPUT:

foo#foo_ehh113#The password of user 111 will expire within the next seven d
foo#foo_ehh204#The password of user 111 will expire within the next seven d
foo#foo_ehh204#The password of user 222 will expire within the next seven da
foo#foo_ehh113#The password of user 222 will expire within the next seven da
foo#foo_ehh113#The password of user 333 will expire within the next seven day
foo#foo_ehh204#The password of user 333 will expire within the next seven day

Portanto, palavras semelhantes nas linhas indicadas são ex .:

The
password
of
user
will
expire
within
the

Minha pergunta: existem métodos para apenas OUTPUT as linhas que são semelhantes a uma extensão? Ex. eles correspondem por 8 palavras
Existe algum script de shell que possa detectar isso?

    
por evachristine 27.07.2014 / 15:22

2 respostas

2

Se você quiser combinar o texto na ordem, tente:

$ grep 'The.*password.*of.*user.*will.*expire.*within.*the' file 
foo#foo_ehh113#The password of user 111 will expire within the next seven d
foo#foo_ehh204#The password of user 111 will expire within the next seven d
foo#foo_ehh204#The password of user 222 will expire within the next seven da
foo#foo_ehh113#The password of user 222 will expire within the next seven da
foo#foo_ehh113#The password of user 333 will expire within the next seven day
foo#foo_ehh204#The password of user 333 will expire within the next seven day

Se você tiver um arquivo para armazenar o grupo de texto, chamado group.txt, você pode usar:

$ grep $(printf "%s.*" $(cat group.txt)) file
    
por 27.07.2014 / 15:43
0

você pode fazer isso inserindo o próximo na linha de comando, você pode dar quantas palavras-chave quiser:

grep -E "one|two|three" file.txt

se a fonte for dmesg do:

dmesg | grep -E "one|two|three" 
    
por 27.07.2014 / 15:36