LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-17-2008, 05:55 AM   #1
akhtar.bhat
Member
 
Registered: Jan 2008
Posts: 34

Rep: Reputation: 15
Arrow Script to extract the fields in the agiml tags


Dear all,



please see the logs shown below:





12-12 08:47:37.545 DBG AGIML SERVER[1]..............................write() (<agiml><header><responsetype>TOPUP</responsetype></header><response><auditfields/><resultcode>999</resultcode>

<account>9773575450</account><transno>1317</transno><incode>BPL</incode><resultdescription></resultdescription><inresultcode>1</inresultcode><inmtransno>229051853686229</inmtransno><flowControlCode></flowControlCode><flowControlLevel></flowControlLevel><intransno></intransno><acls/><authorities/><records/></response></agiml>)


Now i want to write a script which will extract the fields like this



TOPUP,9773575450,1317,BPL,1



these are the fields shown in the different tags.



And one thing more the fields between the tag <agiml>............</agiml>,

it is taking it a single column of log.



example less file | grep "9773575450"

will display the whole line.
 
Old 12-17-2008, 06:13 AM   #2
Felipe
Member
 
Registered: Oct 2006
Posts: 302

Rep: Reputation: 32
If you want that <xxx> disappear and </xxxx> be replaced with ",", you can use:

sed -r "s/<\w+>//g;s/<\/\w+>/,/g"

ex:
echo "<data1>field n1</dat1><data2>field n2</data2>" | sed -r "s/<\w+>//g;s/<\/\w+>/,/g"

will display:
field n1,field n2,

I don't know if this is what you look for....
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash shell script find and edit fields in a file hchoonbeng Programming 9 10-29-2008 02:13 AM
Reading multimedia tags for a script David the H. Linux - General 6 05-06-2008 12:12 PM
script for pasting fields in files bhandu Linux - Newbie 2 06-28-2007 07:20 AM
script to relay the data in the fields to my email address generalachoo Programming 4 08-25-2006 07:54 AM
Bash script for correcting HTML tags hq4ever Programming 4 11-08-2004 04:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration