Register
It is currently Fri Nov 28, 2014 3:36 am

New to SED and AWK


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sun Mar 30, 2014 12:18 am   

Joined: Sun Mar 30, 2014 12:10 am
Posts: 2
[A-Z]\d+\.\d+\.\d+

Can anyone explain why the above regex expression is valid but does not work with SED?

I have been trying to parse out file with the SED command and data below , but get no results.

sed -ne '/[A-Z]\d+\.\d+\.\d+/p' INPUTFILE

Sample Data
<channel id="I3.1.290921215.microsoft.com">
<display-name>3.1 WBQMLD</display-name>
<display-name>3.1</display-name>
<display-name>50 WBQMLD fcc</display-name>
<display-name>WBQMLD</display-name>
<display-name>WBQMLD (WBQM-LD)</display-name>
<display-name>Low Power</display-name>
</channel>


Top
 Profile  
 PostPosted: Sun Mar 30, 2014 12:30 pm   

Joined: Sun Mar 30, 2014 12:10 am
Posts: 2
i have figure out that there is no \d (any digit) in SED, [0-9] must be used instead. the command line should be

sed -ne '/[A-Z][0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}/p'

Also, the bracket { } must be escaped. \{ \} when they are used to specify one or many.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP