The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to print data between 2 lines in a file kamesh83 UNIX for Advanced & Expert Users 4 4 Weeks Ago 05:11 PM
Adding words to beginning of lines Ernst Shell Programming and Scripting 9 04-03-2008 11:23 AM
Ignore some lines with specific words from file comparison jakSun8 Shell Programming and Scripting 2 03-12-2008 09:11 PM
Delete lines that contain 3 or more words? revax Shell Programming and Scripting 5 12-11-2007 03:33 PM
To split a string to obtain the words delimited by whitespaces Sudhakar333 Shell Programming and Scripting 4 08-06-2007 11:26 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-07-2008
Registered User
 

Join Date: Jul 2008
Posts: 3
Grap data/string from lines between words

Hi all,

im newbie in unix, i have a case like this

file name : RegisterSubscriber.log

file value :

<errId>0x0509000000000003</errId><HARs><ok/><affectEntity>510890905290059</affectEntity></HLRes></HRI>

I want to grep the line which contain 0x0509000000000003,
and i want to grep the word between <affectEntity></affectEntity>
that is 510890905290059,

can some one tell me how to doit, i try to use grep but all i got is the whole line

please need your expert advice
Reply With Quote
Forum Sponsor
  #2  
Old 07-07-2008
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,029
Code:
echo '<errId>0x0509000000000003</errId><HARs><ok/><affectEntity>510890905290059</affectEntity></HLRes></HRI>' | sed 's#.*<affectEntity>\(.*\)</affectEntity>.*#\1#'
Reply With Quote
  #3  
Old 08-05-2008
Registered User
 

Join Date: Jul 2008
Posts: 3
wow thanks, its works after i modify some of the code.

thanks
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0