simple regex question
Matthew Gillen
me at mattgillen.net
Thu Jan 11 14:56:14 EST 2007
Dwight E Chadbourne wrote:
> Hi all. I want the 20 digit hash in this text.
>
> d5:filesd20:xxxxxxxxxxxxxxxxxxxxd8:completei2e10:downloadedi0e10:incompletei4e
> 4:name12:xxxxxxxxxxxxee5:flagsd20:min_request_intervali3600eee
>
> How do I get only the xxxxxxxxxxxxxxxxxxxx and not the preceding
> identifier?
>
> filesd20:.{20} returns the "filesd20:" but I don't need that. Is there a
> way to do it only with regex?
>
> Thanks for any tips or links.
set your field separator to ':', and take the first 20 digits of field 3.
Using awk:
awk -F ':' '{ print $3 }'
(you're on your own to figure out the part that takes only the first 20 digits
of $3)
Matt
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the Discuss
mailing list