Sponsored Content
Top Forums Shell Programming and Scripting awk and or sed command to sum the value in repeating tags in a XML Post 302748581 by bk_12345 on Wednesday 26th of December 2012 08:44:02 AM
Old 12-26-2012
awk and or sed command to sum the value in repeating tags in a XML

I have a XML in which <Amt Ccy="EUR">3.1</Amt> tag repeats. This is under another tag <Main>. I need to sum all the values of <Amt Ccy=""> (Ccy may vary) coming under <Main> using awk and or sed command.

can some help?

Sample looks like below

Code:
<root>
    <Main>
            <someothertag>..</someothertag>
        <Amt Ccy="EUR">3.1</Amt>
    </Main>
                .
                .
                .
                some other tags
    <Main>
          <someothertag>..</someothertag>
             <Amt Ccy="SGD">51</Amt>
    </Main>
    <another>
      <Amt Ccy="EUR">10</Amt>
     </another>
</root>


Last edited by bk_12345; 12-27-2012 at 04:05 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help sum columns by break in first column with awk or sed or something.

I have some data that is something like this? item: onhand counted location ITEM0001 1 0 a1 ITEM0001 0 1 a2 ITEM0002 5 0 b5 ITEM0002 0 6 c1 I want to sum up... (6 Replies)
Discussion started by: syadnom
6 Replies

2. Shell Programming and Scripting

Repeating awk command

Hi all, I have an awk command that needs to be ran multiple times in a script on one file containing lots of fields of data. The file look like this (the numbers are made up): 1234 2222 2223 2222 123 2223 3333 2323 3333 3321 3344 4444 The... (2 Replies)
Discussion started by: nistleloy
2 Replies

3. UNIX for Dummies Questions & Answers

Using sed command to remove multiple instances of repeating headers in one file?

Hi, I have catenated multiple output files (from a monte carlo run) into one big output file. Each individual file has it's own two line header. So when I catenate, there are multiple two line headers (of the same wording) within the big file. How do I use the sed command to search for the... (1 Reply)
Discussion started by: rebazon
1 Replies

4. UNIX for Dummies Questions & Answers

Awk: print all URL addresses between iframe tags without repeating an already printed URL

Here is what I have so far: find . -name "*php*" -or -name "*htm*" | xargs grep -i iframe | awk -F'"' '/<iframe*/{gsub(/.\*iframe>/,"\"");print $2}' Here is an example content of a PHP or HTM(HTML) file: <iframe src="http://ADDRESS_1/?click=5BBB08\" width=1 height=1... (18 Replies)
Discussion started by: striker4o
18 Replies

5. UNIX for Dummies Questions & Answers

xml to csv using sed and awk command

Hi Guys, Can you help me in creating shell script using sed,awk etc commands to generate csv file using xml file. (5 Replies)
Discussion started by: sbk
5 Replies

6. Shell Programming and Scripting

Shell script to extract data in repeating tags from xml

Hi, I am new to shell scripting. I need to extract data between repeating tags from an xml file and store the data in an array to process it further. <ns1:root xmlns:ns1="http://example.com/config"> <ns1:interface>in1</ns1:interface> <ns1:operation attribute1="true" attribute2="abd"... (2 Replies)
Discussion started by: sailendra
2 Replies

7. Shell Programming and Scripting

Shell Command to compare two xml lines while ignoring xml tags

I've got two different files and want to compare them. File 1 : HTML Code: <response ticketId="944" type="getQueryResults"><status>COMPLETE</status><description>Query results fetched successfully</description><recordSet totalCount="1" type="sms_records"><record... (1 Reply)
Discussion started by: Shaishav Shah
1 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

Indexing each repeating pattern of rows in a column using awk/sed

Hello All, I have data like this in a column. 0 1 2 3 0 3 4 5 6 0 1 2 3 etc. where 0 identifies the start of a pattern in my data. So I need the output like below using either awk/sed. 0 1 (2 Replies)
Discussion started by: ks_reddy
2 Replies

10. Shell Programming and Scripting

Sum value using sed or awk ?

Hello all, how would one go about writing a command using sed/awk that will give me an output that can sum up the number of time each user has done something and also add the amount of time... so output would be for example "smiths has run 3 process and for time taken of value: 224" ... (5 Replies)
Discussion started by: crazy_max
5 Replies
M_TAG(9)						   BSD Kernel Developer's Manual						  M_TAG(9)

NAME
m_tag, m_tag_get, m_tag_free, m_tag_prepend, m_tag_unlink, m_tag_delete, m_tag_delete_chain, m_tag_delete_nonpersistent, m_tag_find, m_tag_copy, m_tag_copy_chain, m_tag_init, m_tag_first, m_tag_next -- mbuf tagging interfaces SYNOPSIS
#include <sys/mbuf.h> struct m_tag * m_tag_get(int type, int len, int wait); void m_tag_free(struct m_tag *t); void m_tag_prepend(struct mbuf *m, struct m_tag *t); void m_tag_unlink(struct mbuf *m, struct m_tag *t); void m_tag_delete(struct mbuf *m, struct m_tag *t); void m_tag_delete_chain(struct mbuf *m, struct m_tag *t); void m_tag_delete_nonpersistent(struct mbuf *); struct m_tag * m_tag_find(struct mbuf *m, int type, struct m_tag *t); struct m_tag * m_tag_copy(struct m_tag *m); int m_tag_copy_chain(struct mbuf *to, struct mbuf *from); void m_tag_init(struct mbuf *m); struct m_tag * m_tag_first(struct mbuf *m); struct m_tag * m_tag_next(struct mbuf *m, struct m_tag *t); DESCRIPTION
The m_tag interface is used to ``tag'' mbufs. FUNCTIONS
m_tag_get(type, len, wait) Allocate an mbuf tag. type is one of the PACKET_TAG_ macros. len is the size of the data associated with the tag, in bytes. wait is either M_WAITOK or M_NOWAIT. m_tag_free(t) Free the mbuf tag t. m_tag_prepend(m, t) Prepend the mbuf tag t to the mbuf m. t will become the first tag of the mbuf m. When m is freed, t will also be freed. m_tag_unlink(m, t) Unlink the mbuf tag t from the mbuf m. m_tag_delete(m, t) The same as m_tag_unlink() followed by m_tag_free(). m_tag_delete_chain(m, t) Unlink and free mbuf tags beginning with the mbuf tag t from the mbuf m. If t is NULL, m_tag_delete_chain() unlinks and frees all mbuf tags associated with the mbuf m. m_tag_delete_nonpersistent(m) Unlink and free all non persistent tags associated with the mbuf m. m_tag_find(m, type, t) Find an mbuf tag with type type after the mbuf tag t in the tag chain associated with the mbuf m. If t is NULL, search from the first mbuf tag. If an mbuf tag is found, return a pointer to it. Otherwise return NULL. m_tag_copy(t) Copy an mbuf tag t. Return a new mbuf tag on success. Otherwise return NULL. m_tag_copy_chain(to, from) Copy all mbuf tags associated with the mbuf from to the mbuf to. If to already has any mbuf tags, they will be unlinked and freed beforehand. Return 1 on success. Otherwise return 0. m_tag_init(m) Initialize mbuf tag chain of the mbuf m. m_tag_first(m) Return the first mbuf tag associated with the mbuf m. Return NULL if no mbuf tags are found. m_tag_next(m, t) Return the next mbuf tag after t associated with the mbuf m. Return NULL if t is the last tag in the chain. CODE REFERENCES
The mbuf tagging interfaces are implemented within the file sys/kern/uipc_mbuf2.c. The PACKET_TAG_ macros are defined in the file sys/sys/mbuf.h. SEE ALSO
intro(9), malloc(9), mbuf(9) BUGS
The semantics of the term "persistent tag" are vague. BSD
September 7, 2004 BSD
All times are GMT -4. The time now is 04:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy