Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

simple regex question



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.





BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org