![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| grep problem | yogesh_powar | Shell Programming and Scripting | 2 | 11-09-2006 03:43 PM |
| grep problem | asal_email2 | UNIX for Dummies Questions & Answers | 4 | 06-22-2005 05:49 PM |
| problem with grep | vivekshankar | UNIX for Dummies Questions & Answers | 7 | 05-25-2005 10:49 AM |
| grep problem | svennie | UNIX for Dummies Questions & Answers | 5 | 11-08-2004 01:29 AM |
| grep problem | xiamin | UNIX for Dummies Questions & Answers | 4 | 09-06-2001 06:26 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
grep and cut problem
Hello folks,
I have to (e)grep out a certain pattern e.g. <TAG1> from a huge log file which does not have any space as such. The thing is that once I have 'grep'ed out the <TAG1> from the file I need to extract the content within the tags, i.e, <TAG1>Data_To_Be_Extracted</TAG1> The underlined data needs to be extracted. The problem is that with such a huge file with big wide lines with lots of tags I can't get hold of any delimiter. Thanks in advance. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
sed 's/.*<TAG1>\([^>]*\)<\/TAG1>.*/\1/g' |
|
#3
|
|||
|
|||
|
I am sorry Zaxxon but wont this be just replacing the stuff? Please forgive my incompetence with sed. Is there any subString sort of functionality in UNIX?
|
|
#4
|
||||
|
||||
|
It can often be easier to understand when we see actual data, as opposed to answering a theoretical question.
|
|
#5
|
|||
|
|||
|
Nodding to joeyg, I can say that the sed code was working with your example, see yourself:
Code:
root@isau02:/data/tmp/testfeld> cat infile2 somelala.awno2irbn8sp+0<TAG1>Data_To_Be_Extracted</TAG1>some more data or is it rubbish or blaapowjdaowih2 xawmwduhawudhguvsiu31ell.wor8sp+0<TAG1>Data_To_Be_Extracted</TAG1>jscb akjbfq23jrbfhhhh3 aukwdhaiubf23__fgv<TAG1>Data_To_Be_Extracted</TAG1>e mot ri t ubs rjsa 3221u3r root@isau02:/data/tmp/testfeld> sed 's/.*<TAG1>\([^>]*\)<\/TAG1>.*/\1/g' infile2 Data_To_Be_Extracted Data_To_Be_Extracted Data_To_Be_Extracted root@isau02.debeka.de:/data/tmp/testfeld> |
|
#6
|
|||
|
|||
|
Thanks a lot Zaxxon
sed 's/.*<TAG1>\([^>]*\)<\/TAG1>.*/\1/g' $fileName it is returning the entire file. Note: There are multiple occurences of <TAG1>. Last edited by Rajat; 07-23-2008 at 09:41 AM. |
|
#7
|
|||
|
|||
|
i guess it's just working with just one particular file for some weird reason ... any suggestions people?
|
|||
| Google The UNIX and Linux Forums |
| Tags |
| regex, regular expressions |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|