Sponsored Content
Top Forums Shell Programming and Scripting XML parsing using nawk help needed Post 302637029 by busyboy on Tuesday 8th of May 2012 09:10:34 AM
Old 05-08-2012
just an idea...of you really need to be rough..

Code:
BEGIN { print "RNC   UtranCell   cId   uarfcnUl   uarfcnDl   primaryScramblingCode   primaryCpichPower   maximumTransmissionPower   primarySchPower   secondarySchPower   bchPower   lac   rac   sac   cellReserved   administrativeState";print; )

/MeContext/ ' { a=gsub(/[^[:alnum:]]/, " ", $0); RNC=a[4]; }
/UtranCell/ {  a=gsub(/[^[:alnum:]]/, " ", $0); UTRANCELL=a[4]; }
/uarfcnUl/  { a=gsub(/[^[:alnum:]]/, " ", $0);  UARFCNUL=a[3]; }
/uarfcnDl/ { a=gsub(/[^[:alnum:]]/, " ", $0);  UARFCNDL=a[3]; }
/unprimaryScramblingCode/ { a=gsub(/[^[:alnum:]]/, " ", $0);  PRIMARYSCRAMBLINGCODE=a[2]; }
/unprimaryCpichPower/ { a=gsub(/[^[:alnum:]]/, " ", $0); PRIMARYCIPHERPOWER=a[2];}
/maximumTransmissionPower/ {a=gsub(/[^[:alnum:]]/, " ", $0); MAXTRXNPOWER=a[3]; }
/unprimarySchPower/ { a=gsub(/[^[:alnum:]]/, " ", $0);  PRIMARYSCHPOWER=a[2] ;}
/secondarySchPower/ { a=gsub(/[^[:alnum:]]/, " ", $0); SCNDRYSCHPOWER=a[3]; }
/bchPower/ { a=gsub(/[^[:alnum:]]/, " ", $0); BCHPOWER=a[3]; 
printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s", RNC, UTRANCELL, UARFCNUL,UARFCNDL, PRIMARYSCRAMBLINGCODE, PRIMARYCIPHERPOWER, MAXTRXNPOWER, PRIMARYSCHPOWER, SCNDRYSCHPOWER, BCHPOWER ); }' input.xml

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing xml using awk - more help needed

As per another thread - https://www.unix.com/shell-programming-scripting/81027-how-can-i-parse-xml-file-2.html I am using the following to extract the Subaccid and RecAccTotal from the xm file below awk -v v=SubaccId -F'' '$2==v{s=$3;getline;a+=$3}END {for (i in a)print v,i,a}' file Can... (6 Replies)
Discussion started by: frustrated1
6 Replies

2. Shell Programming and Scripting

nawk help needed

guys, i need help the file $ cat file1 1 2 3 4 5 6 7 8 9 my script $ cat nawk1 #!/bin/sh echo "from column? :\c" read c1 echo "until column? :\c" read c2 cat file1 | nawk `{ print $c1, $c2 }` result $ ./nawk1 (3 Replies)
Discussion started by: ajiep
3 Replies

3. Shell Programming and Scripting

parsing(xml) using nawk/awk

Hi , I have an xml format as shown below: <Info> <last name="sean" first name="john"/> <period="5" time="11"/> <test value="1",test2 value="2",test3 value="3",test4 value="5"> <old> <value1>1</value1> <value2>2</value2> </old> <new> <value1>4</value1> <value2>3</value2> </new>... (1 Reply)
Discussion started by: natalie23
1 Replies

4. Shell Programming and Scripting

how to parse the file in xml format using awk/nawk

Hi All, I have an xml file with the below format. <a>111</a><b>222</b><c>333<c><d><e>123</e><f>234</f><d><e>456</e><f>789</f> output needed is 111,222,333,123,234 111,222,333,456,789 nawk 'BEGIN{FS="<|>"} {print a,b,c,e,f a="" ... (7 Replies)
Discussion started by: natalie23
7 Replies

5. Shell Programming and Scripting

nawk help needed

HI, i have input files.it have comma separated records but with some leading and trailing spaces.names of input files,(you may use any dummy comma delimited input records) ls /u01 eG_20100805_0000504_110208 eG_20100805_0000505_121154 eG_20100805_0000506_130233 i need single output... (1 Reply)
Discussion started by: malikshahid85
1 Replies

6. Shell Programming and Scripting

Help in parsing xml file (sed/nawk)

I have a large xml file as shown below: <input> <blah> <blah> <atr="blah blah value = ""> <blah> <blah> </input> ..2nd chunk... ..3rd chunk... ...4th chunk... All lines between <input> and </input> is one 'order' and this 'order' is repeated... (14 Replies)
Discussion started by: shekhar2010us
14 Replies

7. Shell Programming and Scripting

Help needed for parsing large XML with awk.

My XML structure looks like: <?xml version="1.0" encoding="UTF-8"?> <SearchRepository> <SearchItems> <SearchItem> ... </SearchItem> <SearchItem> ... ... (1 Reply)
Discussion started by: jasonjustice
1 Replies

8. Shell Programming and Scripting

Need help parsing data with sed and/or nawk

Good day all. I have the following entries of data in a file in a column, however, I need this data written on a single line with several parameters in a different order. Current format: Treatment ,parmeter1=value ,parmeter2=value ,parmeter3=value ,parmeter4=value... (7 Replies)
Discussion started by: BRH
7 Replies

9. Shell Programming and Scripting

XML: parsing of the Google contacts XML file

I am trying to parse the XML Google contact file using tools like xmllint and I even dived into the XSL Style Sheets using xsltproc but I get nowhere. I can not supply any sample file as it contains private data but you can download your own contacts using this script: #!/bin/sh # imports... (9 Replies)
Discussion started by: ripat
9 Replies

10. Shell Programming and Scripting

XML parsing

i have xml output in below format... <AlertsResponse> <Alert id="11216" name="fgdfg"> <AlertActionLog timestamp="1356521629778" user="admin" detail="Recovery Alert"/> </Alert> <Alert id="11215" name="gdfg <AlertActionLog timestamp="1356430119840" user=""... (12 Replies)
Discussion started by: vivek d r
12 Replies
ucblinks(1B)					     SunOS/BSD Compatibility Package Commands					      ucblinks(1B)

NAME
ucblinks - adds /dev entries to give SunOS 4.x compatible names to SunOS 5.x devices SYNOPSIS
/usr/ucb/ucblinks [-e rulebase] [-r rootdir] DESCRIPTION
ucblinks creates symbolic links under the /dev directory for devices whose SunOS 5.x names differ from their SunOS 4.x names. Where possi- ble, these symbolic links point to the device's SunOS 5.x name rather than to the actual /devices entry. ucblinks does not remove unneeded compatibility links; these must be removed by hand. ucblinks should be called each time the system is reconfiguration-booted, after any new SunOS 5.x links that are needed have been created, since the reconfiguration may have resulted in more compatibility names being needed. In releases prior to SunOS 5.4, ucblinks used a nawk rule-base to construct the SunOS 4.x compatible names. ucblinks no longer uses nawk for the default operation, although nawk rule-bases can still be specifed with the -e option. The nawk rule-base equivalent to the SunOS 5.4 default operation can be found in /usr/ucblib/ucblinks.awk. OPTIONS
-e rulebase Specify rulebase as the file containing nawk(1) pattern-action statements. -r rootdir Specify rootdir as the directory under which dev and devices will be found, rather than the standard root directory /. FILES
/usr/ucblib/ucblinks.awk sample rule-base for compatibility links ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
devlinks(1M), disks(1M), ports(1M), tapes(1M), attributes(5) SunOS 5.10 13 Apr 1994 ucblinks(1B)
All times are GMT -4. The time now is 10:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy