Sponsored Content
Full Discussion: get xml note by awk
Top Forums Shell Programming and Scripting get xml note by awk Post 302632377 by itkamaraj on Monday 30th of April 2012 02:42:24 AM
Old 04-30-2012
Code:
 
$ nawk -F"[<>]" -v var="a" '{for(i=1;i<=NF-1;i++)if($i~var){print $(i+1);next}}' test.txt
1
1
1
1
$ nawk -F"[<>]" -v var="b" '{for(i=1;i<=NF-1;i++)if($i~var){print $(i+1);next}}' test.txt
2
2
2
2
$ nawk -F"[<>]" -v var="c" '{for(i=1;i<=NF-1;i++)if($i~var){print $(i+1);next}}' test.txt
3
33
66
77
$ cat test.txt
<a>1</a><b>2</b><c>3</c><d>4</d><e>5</e><f>64</f>
<a>1</a><b>2</b><c>33</c><d>4</d><e>56</e><f>63</f>
<a>1</a><b>2</b><c>66</c><d>4</d><e>58</e><f>62</f>
<a>1</a><b>2</b><c>77</c><d>4</d><e>59</e><f>61</f>

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

XML Awk : Urgent

Hi All, I am a beginner to Unix. So would really appreciate if people out here can help me out. I have a XML file which has a element <NoteData> in which two values DBHA and DAKO. I need to search these in all the XML files in a directory and if found in the XML file then replace the... (3 Replies)
Discussion started by: karansachdeva
3 Replies

2. Shell Programming and Scripting

parsing xml using awk

hello , i am trying to parse xml using awk however its a little bit tricky as i want <databases> <source> <host>prod</host> <port>1522</port> <tns>GP1</tns> <user>P11</user>... (6 Replies)
Discussion started by: amit1_x
6 Replies

3. Shell Programming and Scripting

Read content between xml tags with awk, grep, awk or what ever...

Hello, I trying to extract text that is surrounded by xml-tags. I tried this cat tst.xml | egrep "<SERVER>.*</SERVER>" |sed -e "s/<SERVER>\(.*\)<\/SERVER>/\1/"|tr "|" " " which works perfect, if the start-tag and the end-tag are in the same line, e.g.: <tag1>Hello Linux-Users</tag1> ... (5 Replies)
Discussion started by: Sebi0815
5 Replies

4. Shell Programming and Scripting

awk XML

ho un file xml vorrei fare due cose: eliminare tutto il testo prima del tag <prodottti> e dopo la fine del tag </prodotti> sostituire i caratteri cr e lf con blank Come fare ?? Grazie. (3 Replies)
Discussion started by: alice07
3 Replies

5. Shell Programming and Scripting

processing xml with awk

With the following input sample extracted from a xml file <rel ver="123"> <mod name="on"> <node env="ac" env="1"> <ins ip="10.192.0.1"/> <ins ip="10.192.0.2"/> ... (1 Reply)
Discussion started by: cabrao
1 Replies

6. Shell Programming and Scripting

xml parsing with awk

hi all.. need your help again.. i have xml file and i want to parsing some data from the xml file.. <ex-name="keroco"> <................> <................> <................> <br-name="cincai"> <ship="123456"> <...................> ... (3 Replies)
Discussion started by: buncit8
3 Replies

7. Shell Programming and Scripting

XML Parsing using awk

Hi All, I have a problem to resolve. For following XML file, I need to parse the values based on Tag Name. I would prefer to use this by awk. I have used sed command to replace the tags (s/<SeqNo>//). In this case there can be new tags introduced. So need to parse it based on Tag Name. Any... (9 Replies)
Discussion started by: Tons
9 Replies

8. Shell Programming and Scripting

How to add Xml tags to an existing xml using shell or awk?

Hi , I have a below xml: <ns:Body> <ns:result> <Date Month="June" Day="Monday:/> </ns:result> </ns:Body> i have a lookup abc.txtt text file with below details Month June July August Day Monday Tuesday Wednesday I need a output xml with below tags <ns:Body> <ns:result>... (2 Replies)
Discussion started by: Nevergivup
2 Replies

9. Shell Programming and Scripting

XML Phase with awk

Hi Guys, Input XML File :- <managedObject class="RMOD_R" distName="MRBTS-101/X/R-7"> <list name="activeCellsList"> <p>15</p> <p>201</p> </list> <p name="aldManagementProtocol">True</p> <p name="serialNumber">845</p> </managedObject> Output :- ... (5 Replies)
Discussion started by: pareshkp
5 Replies

10. Shell Programming and Scripting

Note: environment variables within awk

This is not a question. Just a little note, because I've been here some time and never read about awk accessing environment variables. So here's my use case and demonstration of how to use the ENVIRON array. My operating environment is ubuntu 18.04 / docker / GNU awk 4.1.4. ENVIRON seems to posix... (2 Replies)
Discussion started by: stomp
2 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 12:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy