Sponsored Content
Full Discussion: parse xm entry with awk/sed
Top Forums Shell Programming and Scripting parse xm entry with awk/sed Post 302523873 by euval on Friday 20th of May 2011 05:49:41 AM
Old 05-20-2011
parse xm entry with awk/sed

Hi folks,

I have XML files with the following sections (section occurs once per file) in them:
Code:
 <AuthorList CompleteYN="Y">
                <Author ValidYN="Y">
                    <LastName>Bernal</LastName>
                    <ForeName>Federico</ForeName>
                    <Initials>F</Initials>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Tyler</LastName>
                    <ForeName>Andrew F</ForeName>
                    <Initials>AF</Initials>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Korsmeyer</LastName>
                    <ForeName>Stanley J</ForeName>
                    <Initials>SJ</Initials>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Walensky</LastName>
                    <ForeName>Loren D</ForeName>
                    <Initials>LD</Initials>
                </Author>
                <Author ValidYN="Y">
                    <LastName>Verdine</LastName>
                    <ForeName>Gregory L</ForeName>
                    <Initials>GL</Initials>
                </Author>
            </AuthorList>

I'm trying to incorporate an awk/sed function into a script which will print out the following output:
Code:
Federico Bernal, Andrew F Tyler, Stanley J Korsmeyer, Loren D Walensky, Gregory L Verdine

I've been experimenting with split and if/for loops in awk but can't seem to get first and last names on one line!

Thanks in advance for any help.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Muilti Entry Sed

My defaul shell is /bin/ksh I want to make multi entry sed changes to files mainly because is easier for me to check my arguments in that format, than all in just one line. example sed ' > s/this/for this/ > s/that/for that/ > s/I/me/' filex > filez Searching the net I read... (2 Replies)
Discussion started by: tony3101
2 Replies

2. Shell Programming and Scripting

To parse through the file and print output using awk or sed script

suppose if u have a file like that Hen ABCCSGSGSGJJJJK 15 Cock ABCCSGGGSGIJJJL 15 * * * * * * : * * * . * * * : Hen CFCDFCSDFCDERTF 30 Cock CHCDFCSDHCDEGFI 30 * . * * * * * * * : * * :* : : . The output shud be where there is : and . It shud... (4 Replies)
Discussion started by: cdfd123
4 Replies

3. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

4. Shell Programming and Scripting

awk/sed Command: To Parse Stament between 2 numbers

Hi, I need an awk command that would parse the below expression Input Format 1 'Stmt1 ............................'2 'Stmt2 ............................'3 'Stmt3 ............................'4 'Stmt4 ............................'5 'Stmt5 ............................'6 'Stmt6... (1 Reply)
Discussion started by: rajan_san
1 Replies

5. Shell Programming and Scripting

sed or awk to parse this text

I am just beginning with sed and awk and understand that they are "per" line input. That is, they operate on each line individually, and output based on rules, etc. But I have multi-line text blocks that looks as follows, and wish to ONLY extract the text between the first hyphen (-) and the... (13 Replies)
Discussion started by: bulgin
13 Replies

6. Shell Programming and Scripting

Use awk or sed to parse delimited string

Hi I am trying to figure out the best way to search a long log file and print out certain information. For example if I had a line in a log file delimited by ampersand first_name=mike&last_name=smith&zip_code=55555&phone=555-5555&state=ma&city=boston and I only wanted to search for and... (3 Replies)
Discussion started by: mstefaniak
3 Replies

7. Shell Programming and Scripting

sed/awk script to parse list of bandwidth rules

Hello all gurus, I have a long list of rules as below: 20 name:abc addr:203.45.247.247/255.255.255.255 WDW-THRESH:12 BW-OUT:10000000bps BW-IN:15000000bps STATSDEVICE:test247 STATS:Enabled (4447794/0) <IN OUT> 25 name:xyz160 addr:203.45.233.160/255.255.255.224 STATSDEVICE:test160... (3 Replies)
Discussion started by: sb245
3 Replies

8. Shell Programming and Scripting

Replacing specific entry using sed

Hi guys, I'm new to bash programming, so please pardon me. I'm trying to replace an entry's text in Books.txt This code works perfectly: sed -i "s/$BookTitle/$NewBookTitle/g" Books.txt But problem is, if there are double entries, it will also replace that entry. For example: ... (12 Replies)
Discussion started by: todaealas
12 Replies

9. Shell Programming and Scripting

How to replace multiple "&nbsp;" entry with in <td> tag into single entry using sed?

I have the input file like this. Input file: 12.txt 1) There are one or more than one <tr> tags in same line. 2) Some tr tags may have one <td> or more tna one <td> tags within it. 3) Few <td> tags having "<td> &nbsp; </td>". Few having more than one "&nbsp;" entry in it. <tr> some td... (4 Replies)
Discussion started by: thomasraj87
4 Replies

10. UNIX for Beginners Questions & Answers

Awk/sed summation of one column based on some entry in first column

Hi All , I am having an input file as stated below Input file 6 ddk/djhdj/djhdj/Q 10 0.5 dhd/jdjd.djd.nd/QB 01 0.5 hdhd/jd/jd/jdj/Q 10 0.5 512 hd/hdh/gdh/Q 01 0.5 jdjd/jd/ud/j/QB 10 0.5 HD/jsj/djd/Q 01 0.5 71 hdh/jjd/dj/jd/Q 10 0.5 ... (5 Replies)
Discussion started by: kshitij
5 Replies
XScreenSaver(1) 					      General Commands Manual						   XScreenSaver(1)

NAME
vermiculate - to move in a worm-like manner. SYNOPSIS
vermiculate [-display host:display.screen] [-visual visual] [-window] [-root] DESCRIPTION
Draws squiggly worm-like paths. OPTIONS
-visual visual Specify which visual to use. Legal values are the name of a visual class, or the id number (decimal or hex) of a specific visual. -window Draw on a newly-created window. This is the default. -root Draw on the root window. ENVIRONMENT
DISPLAY to get the default host and display number. XENVIRONMENT to get the name of a resource file that overrides the global resources stored in the RESOURCE_MANAGER property. SEE ALSO
X(1), xscreensaver(1) COPYRIGHT
Copyright (C) 2002 by Tyler Pierce. Permission to use, copy, modify, distribute, and sell this software and its documentation for any pur- pose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. No representations are made about the suitability of this software for any pur- pose. It is provided "as is" without express or implied warranty. AUTHOR
Tyler Pierce. X Version 11 XScreenSaver(1)
All times are GMT -4. The time now is 02:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy