Web Development

Our forums are currently in maintenance mode and the ability to post is disabled. We will be back up and running as soon as possible. Thanks for your patience!

General discussion

Locked

Unix Script

By avazquez65 ·
I need to create a script shell to select some information from a XML source file.
- <Section 1>
- <AddressInfo>
<ContactName>first last</ContactName>
<CompanyName>company</CompanyName>
<AddressLine1>addr1</AddressLine1>
<AddressLine2>addr22222</AddressLine2>
<AddressLine3>addr3333</AddressLine3>
<City>Brisbane</City>
<PostalCode>000</PostalCode>
<CountryCode>AU</CountryCode>
<PhoneNumber>12345</PhoneNumber>
<PhoneExtension>123</PhoneExtension>
<FaxNumber>12345</FaxNumber>
<Email>email@rr.com</Email>
- <Section 2>
- <AddressInfo>
<ContactName>brazil1</ContactName>
- <Section 3>
- <AddressInfo>
<ContactName>Johnathan Seagull</ContactName>
<CompanyName>Sheraton Australia</CompanyName>
<AddressLine1>207 Golden Lawn Terrace</AddressLine1>
<City>Brisbane</City>
<PostalCode>4000</PostalCode>
<DivisionCode>QL</DivisionCode>
<DivisionName>Queensland</DivisionName>
<CountryCode>AU</CountryCode>
<PhoneNumber>(61)( 9224 7777</PhoneNumber>
<PhoneExtension>45232</PhoneExtension>
<FaxNumber>(61)( 9224 7788</FaxNumber>
<Email>sheraton@au.com</Email>

From section 1:
I need to get the folowing texts:
first last
company
addr1
addr22222
addr3333
Brisbane
000
AU
12345
123
12345
email@rr.com

From section 3:
I need to get the folowing texts:
Johnathan Seagull
Sheraton Australia
207 Golden Lawn Terrace
Brisbane
4000
QL
Queensland
AU
(61)( 9224 7777
45232
(61)( 9224 7788
sheraton@au.com

We used grep, sed, awk, but when we got the information we get at the same time information from the section 1, section 2 and section 3, and we only need information from section 1 and section 3.

I really appreciate your help

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by Martin Simons In reply to Unix Script

Then do the following as the very first action:

sed -e '/<Section 2>/,/<Section 3>/d'

with this you no longer have the "Section 3" header, but the entire Section 2 is deleted.

Collapse -

by avazquez65 In reply to Unix Script

This question was closed by the author

Related Discussions

Related Forums