The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
vi to remove lines in file kjbaumann UNIX for Dummies Questions & Answers 2 03-13-2009 03:40 AM
Remove lines using perl mohan705 UNIX for Advanced & Expert Users 6 06-19-2008 03:22 AM
Remove lines with n columns Krispy Shell Programming and Scripting 2 11-10-2006 05:41 AM
How to remove all lines with something other than numbers Juha Shell Programming and Scripting 2 09-21-2006 04:48 PM
remove unnecessary lines nazri UNIX for Dummies Questions & Answers 3 11-23-2001 08:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-05-2008
kumar66 kumar66 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 9
Need to remove lines

Hi All,

I have a xml file . And I need to remove the header inofrmation and the tralier information from the xml file. I have pasted the sample xml below:

<?xml version="1.0" encoding="UTF-8" ?>
- <!-- Generated by Ascential Software Corporation, DataStage - XMLOutput stage - Mon Nov 19 15:49:21 2007
-->
- <xtd:EBO xmlns:xtd="http://service.aaaa.com/GenericSchema" xmlns:esb="http://service.aaaa.com/schemas/ESBHeader" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <esb:ESBHeader>
<esb:EnvironmentName>Development</esb:EnvironmentName>
<esb:VersionNbr>1.0</esb:VersionNbr>
- <esb:BusinessEvent>
<esb:TransactionTypeCode>PurchaseOrderFullRfh</esb:TransactionTypeCode> <esbescription>Purchase _Order_Refresh</esbescription>
<esb:Timestamp>2007-11-19 15:49:12</esb:Timestamp>
<esb:TotalRecordCount>34</esb:TotalRecordCount>
<esb:EventID>111</esb:EventID>
</esb:BusinessEvent>
- <esb:SourceSystem>
<esb:ApplicationName>DWA</esb:ApplicationName>
</esb:SourceSystem>
- <esb:RoutingInformation>
- <esb:Type>
<esb:LabelName>Transaction_Type</esb:LabelName>
<esb:RoutingTypeName>Transaction</esb:RoutingTypeName>
<esb:LabelValueText>Purchase_order</esb:LabelValueText>
</esb:Type>
</esb:RoutingInformation>
- <esbatasetInfo>
<esbatasetSizeQty>30</esbatasetSizeQty>
<esb:TotalDatasetCount>2</esb:TotalDatasetCount>
<esbatasetNbr>1</esbatasetNbr>
<esb:KeyField2>1</esb:KeyField2>
</esbatasetInfo>
</esb:ESBHeader>
- <xtd:EBOPayload>
- <xtdata>
<![CDATA[
0000082973|0000000004|QP799-MA|HOL 2002|0000000001|01|0000000002|
0000073994|0000000004|KS754-5A|BAS 9999|0000000092|11|0000000093|
0000081982|0000000004|QP799-VA|HOL 2002|0000000001|01|0000000002|
0000082975|0000000004|QP799-YA|HOL 2002|0000000001|01|0000000002|
]]>
</xtdata>
</xtd:EBOPayload>
</xtd:EBO>


Bascially I need to remove the lines from header to "<![CDATA[" and the lines line from "]]>" to the end.

Please Advise.

Thanks & Regards,
Kumar66
  #2 (permalink)  
Old 10-05-2008
danmero danmero is online now Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,369
Code:
sed -i '/^[0-9]/p;d' data.file
.. and please read Simple rules of the UNIX.COM forums: before posting, especially 5 and 6.
  #3 (permalink)  
Old 10-06-2008
kumar66 kumar66 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 9
Hi Danmero,

Thanks for your reply . But when I used this command it gives the follwoing error:

sed -i '/^[0-9]/p;d' PurchaseOrderFullRfh.xml

sed: illegal option -- i


Please Advise.

Thanks & Regrads,
Kumar66
  #4 (permalink)  
Old 10-06-2008
danmero danmero is online now Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,369
You should read man sed for your version, and if -in place is not available use a temporary file.
  #5 (permalink)  
Old 10-06-2008
kumar66 kumar66 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 9
Hi Danmero,

I used this "sed '/^[0-9]/p;d' salesxml.xml > sales.txt" and it works fine for me . It removes the header and the tralier.
Is this correct or I need to change anything.

Please Advise.

Thanks & Regards,
Kumar66
  #6 (permalink)  
Old 10-06-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,382
i think it should work..
why do you want to print it?? if not no need to use 'p' in sed
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0