Sponsored Content
Top Forums Shell Programming and Scripting Reading block by block in XML Post 302677249 by agama on Wednesday 25th of July 2012 08:09:23 PM
Old 07-25-2012
You could write a simple awk programme to extract the bits you need.

Code:
awk '
    /^Val.*Db="[^"]+"/ {
        gsub( "^Val ", "" );
        gsub( "=\"", "<" );
        gsub( "\" *", ">" );
        la = split( $0, a, ">" );
        for( i = 1; i <= la; i++ )
        {
            split( a[i], b, "<" );
            h[b[1]] = b[2];
        }

        printf( "%s -> %s\n", h["Db"], h["qry"] );
        delete h;
    }' RS="[<>]"   input-file >output-file

It makes a few assumptions about your code (and that you have GNU awk) which might be wrong, but it works on the small sample you posted and thus might work across all of your input.
This User Gave Thanks to agama For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

Reading a process control block

Hello, I want to know what call to use to read the details of a process control block in solaris ?:) (2 Replies)
Discussion started by: hmurali
2 Replies

2. Shell Programming and Scripting

Read block of lines from xml file

Hi I am new to this forum. I have few XML files and from each xml file I want to copy some specific 50 no of lines and copy them to some other file. how to do that? pls help.. (5 Replies)
Discussion started by: pritam1980
5 Replies

3. Shell Programming and Scripting

Extract selective block from XML file

Hi, There's an xml file produced from a front-end tool as shown below: <INPUT DATABASE ="ORACLE" DBNAME ="UNIX" NAME ="FACT_TABLE" OWNERNAME ="DIPS"> <INPUTFIELD DATATYPE ="double" DEFAULTVALUE ="" DESCRIPTION ="" NAME ="STORE_KEY" PICTURETEXT ="" PORTTYPE ="INPUT" PRECISION ="15" SCALE... (6 Replies)
Discussion started by: dips_ag
6 Replies

4. Shell Programming and Scripting

Script to put block comment after finding regex in xml file

hi, i need my bash script to find regex in xml file.. and comment 2 lines before and after the line that contains regex.. can't use # needs to be <!-- at the beginning and --> and the end of the comment. so eg.. first block <filter> <filter-name>MyRegEx</filter-name> ... (11 Replies)
Discussion started by: Poki
11 Replies

5. Shell Programming and Scripting

How to grab data from xml block?

I tried searching the forums, but couldn't find anything relevant to my question. I have an xml file like the following: <topLevel numberBlock="BLOCK1"> <item="content1" title="Content 1"> <RefPath="path/to/file1.txt /> </item> <item"content2" title="Content 2" >... (4 Replies)
Discussion started by: jl487
4 Replies

6. Shell Programming and Scripting

Uncomment XML block using sed

Hi All, I need to umcomment an XML block (if it's not already uncommented) in a shell script. There are several commented blocks in the file that need to remain commented out. The challenging part for me is that I need to match a comment on one line and an XML tag on the following line. Also,... (0 Replies)
Discussion started by: raiderfan1
0 Replies

7. Shell Programming and Scripting

Printing a block of lines from a file, if that block does not contain two patterns using sed

I want to process a file block by block using sed, and if that block does not contain two patterns, then that complete block has to be printed. See below for the example data. ................................server 1............................... running process 1 running... (8 Replies)
Discussion started by: Kesavan
8 Replies

8. Shell Programming and Scripting

Commenting a block of code in xml where the tags may be similar

I want to comment a block of code in xml. Note that the tags will be similar. In the below xml code, I want to block the listener block for com.pkg1.class2. How do i do it ? Thanks in Advance <listener> <listener-class>com.pkg1.class1</listener-class> </listener> ......... <listener>... (4 Replies)
Discussion started by: Lakshmikumari
4 Replies

9. Shell Programming and Scripting

How can I extract XML block around matching search string?

I want to extract XML block surrounding search string Ex: print XML block for string "myapp1-ear" surrounded by "<application> .. </application>" Input XML: <?xml version="1.0" encoding="UTF-8"?> <deployment-request> <requestor> <first-name>kchinnam</first-name> ... (16 Replies)
Discussion started by: kchinnam
16 Replies

10. UNIX for Beginners Questions & Answers

Extract XML block when value is matched (Shell script)

Hi everyone, So i'm struggling with an xml (log file) where we get information about some devices, so the logfile is filled with multiple "blocks" like that. Based on the <devId> i want to extract this part of the xml file. If possible I want it to have an script for this, cause we'll use... (5 Replies)
Discussion started by: Pouky
5 Replies
allocb_tmpl(9F) 					   Kernel Functions for Drivers 					   allocb_tmpl(9F)

NAME
allocb_tmpl - allocate a message block using a template SYNOPSIS
#include <sys/stream.h> mblk_t *allocb_tmpl(size_t size, const mblk_t *tmpl); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI) PARAMETERS
size The number of bytes in the message block. tmpl The template message block. DESCRIPTION
The allocb_tmpl() function tries to allocate a STREAMS message block using allocb(9F). If the allocation is successful, the db_type field in the the data block structure (dblk_t, see datab(9S)), as well as some implementation-private data, are copied from the dblk_t associated with tmpl. allocb_tmpl() should be used when a new STREAMS message block is allocated. This block is then used to contain data derived from another STREAMS message block. The original message is used as the tmpl argument. RETURN VALUES
Upon success, allocb_tmpl() returns a pointer to the allocated message block of the same type as tmpl. On failure, allocb_tmpl() returns a NULL pointer. CONTEXT
allocb_tmpl() can be called from user or interrupt context. SEE ALSO
allocb(9F), datab(9S), msgb(9S) Writing Device Drivers STREAMS Programming Guide SunOS 5.10 18 Feb 2003 allocb_tmpl(9F)
All times are GMT -4. The time now is 06:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy