[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] Capturar padrão de uma expressão regular
From: |
Cléoson Barreto |
Subject: |
Re: [shell-script] Capturar padrão de uma expressão regular |
Date: |
Tue, 19 May 2009 18:58:24 -0300 |
Olá!
Tentando rapidamente consegui isso:
$ cat arquivo
<pre><img src="/icons/blank.gif" alt="Icon "> <a
href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last
modified</a> <a href="?C=S;O=A">Size</a> <a
href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]">
<a href="/downloads/patches/">Parent
Directory</a> -
<img src="/icons/text.gif" alt="[TXT]"> <a
href="graph_search.patch">graph_search.patch</a> 02-Mar-2009 21:50
1.0K
<img src="/icons/unknown.gif" alt="[ ]"> <a
href="page_length_graph_view.patch">page_length_graph_vi..></a>
02-Mar-2009 21:50 1.4K
<img src="/icons/text.gif" alt="[TXT]"> <a
href="ping_timeout.patch">ping_timeout.patch</a> 02-Mar-2009 21:50
2.4K
<img src="/icons/folder.gif" alt="[DIR]"> <a
href="pre-patched/">pre-patched/</a> 02-Mar-2009 22:05 -
<img src="/icons/text.gif" alt="[TXT]"> <a
href="snmp_string_issue_with_rrdtool_creation.patch">snmp_string_issue_wi..></a>
02-Mar-2009 21:50 336
<hr></pre>
<address>Apache Server at www.cacti.net Port 80</address>
</body></html>
*$ egrep -o "\".*\.patch\"" arquivo | tr -d "\""*
graph_search.patch
page_length_graph_view.patch
ping_timeout.patch
snmp_string_issue_with_rrdtool_creation.patch
Teste antes de usar. :-)
[]'s
Cléoson.
http://farinhadigital.blogspot.com/
2009/5/19 Leonardo <address@hidden>
> Olá,
>
> Tenho um arquivo com o seguinte conteúdo:
>
> <pre><img src="/icons/blank.gif" alt="Icon "> <a
> href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last
> modified</a> <a href="?C=S;O=A">Size</a> <a
> href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]">
> <a href="/downloads/patches/">Parent
> Directory</a> -
> <img src="/icons/text.gif" alt="[TXT]"> <a
> href="graph_search.patch">graph_search.patch</a> 02-Mar-2009 21:50
> 1.0K
> <img src="/icons/unknown.gif" alt="[ ]"> <a
> href="page_length_graph_view.patch">page_length_graph_vi..></a>
> 02-Mar-2009 21:50 1.4K
> <img src="/icons/text.gif" alt="[TXT]"> <a
> href="ping_timeout.patch">ping_timeout.patch</a> 02-Mar-2009 21:50
> 2.4K
> <img src="/icons/folder.gif" alt="[DIR]"> <a
> href="pre-patched/">pre-patched/</a> 02-Mar-2009 22:05 -
> <img src="/icons/text.gif" alt="[TXT]"> <a
>
> href="snmp_string_issue_with_rrdtool_creation.patch">snmp_string_issue_wi..></a>
> 02-Mar-2009 21:50 336
> <hr></pre>
> <address>Apache Server at www.cacti.net Port 80</address>
> </body></html>
>
> e estou interessado em pegar o nome de todos os arquivos que tenham seu
> nome
> terminado com ".patch".
>
> Assim, tentei fazer:
>
> $ cat cacti.html | egrep "*\.patch"
> <img src="/icons/text.gif" alt="[TXT]"> <a
> href="graph_search.patch">graph_search.patch</a> 02-Mar-2009 21:50
> 1.0K
> <img src="/icons/unknown.gif" alt="[ ]"> <a
> href="page_length_graph_view.patch">page_length_graph_vi..></a>
> 02-Mar-2009 21:50 1.4K
> <img src="/icons/text.gif" alt="[TXT]"> <a
> href="ping_timeout.patch">ping_timeout.patch</a> 02-Mar-2009 21:50
> 2.4K
> <img src="/icons/text.gif" alt="[TXT]"> <a
>
> href="snmp_string_issue_with_rrdtool_creation.patch">snmp_string_issue_wi..></a>
> 02-Mar-2009 21:50 336
>
> Beleza, só que agora eu não sei como faço para capturar apenas a parte
> usada
> como parâmetro do href, como, por exemplo, graph_search.patch.
>
> Qual ferramenta ou comando eu poderia usar para ter como saída apenas a
> lista dos arquivos que são referenciados nesses href's? Tem jeito de fazer
> isso com (e)grep?
>
> Atc,
>
> Leonardo Andrade.
>
> [As partes desta mensagem que não continham texto foram removidas]
>
[As partes desta mensagem que não continham texto foram removidas]