Skip to main content
deleted 61 characters in body
Source Link

My file contains data which is not well idented. Say like:

<?xml version="1.0" encoding="UTF-8" ?><ns0:collection
xmlns:ns0="http://www.nwl.co.uknamspace/BillPrintExtractServiceService/1.0"><Record>
.
.</Record></ns0:collection>

I have to marge file N number of such files and create one file. So I need the following to be done:

  1. I need to remove only </ns0:collection> closing tag from the first file
  2. remove both <?xml version="1.0" encoding="UTF-8" ?><ns0:collection xmlns:ns0="http://www.nwl.co.uknamspace/BillPrintExtractServiceService/1.0"> and   </ns0:collection> in the next (n-1) files
  3. Have to remove only <?xml version="1.0" encoding="UTF-8" ?><ns0:collection xmlns:ns0="http://www.nwl.co.uknamspace/BillPrintExtractServiceService/1.0"> in the last file and merge all of them together

I have tried using sed command to process first file which is not resulting anything, "merged.xml" is empty.

sed '/<\/ns0:collection>/d' $file1 > merged.xml

Any suggestions?

My file contains data which is not well idented. Say like:

<?xml version="1.0" encoding="UTF-8" ?><ns0:collection
xmlns:ns0="http://www.nwl.co.uk/BillPrintExtractService/1.0"><Record>
.
.</Record></ns0:collection>

I have to marge file N number of such files and create one file. So I need the following to be done:

  1. I need to remove only </ns0:collection> closing tag from the first file
  2. remove both <?xml version="1.0" encoding="UTF-8" ?><ns0:collection xmlns:ns0="http://www.nwl.co.uk/BillPrintExtractService/1.0"> and </ns0:collection> in the next (n-1) files
  3. Have to remove only <?xml version="1.0" encoding="UTF-8" ?><ns0:collection xmlns:ns0="http://www.nwl.co.uk/BillPrintExtractService/1.0"> in the last file and merge all of them together

I have tried using sed command to process first file which is not resulting anything, "merged.xml" is empty.

sed '/<\/ns0:collection>/d' $file1 > merged.xml

Any suggestions?

My file contains data which is not well idented. Say like:

<?xml version="1.0" encoding="UTF-8" ?><ns0:collection
xmlns:ns0="http://namspace/Service/1.0"><Record>
.
.</Record></ns0:collection>

I have to marge file N number of such files and create one file. So I need the following to be done:

  1. I need to remove only </ns0:collection> closing tag from the first file
  2. remove both <?xml version="1.0" encoding="UTF-8" ?><ns0:collection xmlns:ns0="http://namspace/Service/1.0"> and   </ns0:collection> in the next (n-1) files
  3. Have to remove only <?xml version="1.0" encoding="UTF-8" ?><ns0:collection xmlns:ns0="http://namspace/Service/1.0"> in the last file and merge all of them together

I have tried using sed command to process first file which is not resulting anything, "merged.xml" is empty.

sed '/<\/ns0:collection>/d' $file1 > merged.xml

Any suggestions?

Shells are not text editors
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265
deleted 4 characters in body
Source Link
Rahul
  • 14k
  • 4
  • 46
  • 56

My file contains data which is not well idented. Say like:

**<<?xml version="1.0" encoding="UTF-8" ?><ns0:collection
xmlns:ns0="http://www.nwl.co.uk/BillPrintExtractService/1.0"><Record>
.
.</Record></ns0:collection>**collection>

I have to marge file N number of such files and create one file. So I need the following to be done:

  1. I need to remove only </ns0:collection> closing tag from the first file
  2. remove both <?xml version="1.0" encoding="UTF-8" ?><ns0:collection xmlns:ns0="http://www.nwl.co.uk/BillPrintExtractService/1.0"> and </ns0:collection> in the next (n-1) files
  3. Have to remove only <?xml version="1.0" encoding="UTF-8" ?><ns0:collection xmlns:ns0="http://www.nwl.co.uk/BillPrintExtractService/1.0"> in the last file and merge all of them together

I have tried using sedsed command to process first file which is not reultingresulting anything . emrged, "merged.xmlxml" is empty. sed '/</ns0:collection>/d' $file1 > merged.xml

sed '/<\/ns0:collection>/d' $file1 > merged.xml

Any suggestions?

My file contains data which is not well idented. Say like:

**<?xml version="1.0" encoding="UTF-8" ?><ns0:collection
xmlns:ns0="http://www.nwl.co.uk/BillPrintExtractService/1.0"><Record>
.
.</Record></ns0:collection>**

I have to marge file N number of such files and create one file. So I need the following to be done:

  1. I need to remove only </ns0:collection> closing tag from the first file
  2. remove both <?xml version="1.0" encoding="UTF-8" ?><ns0:collection xmlns:ns0="http://www.nwl.co.uk/BillPrintExtractService/1.0"> and </ns0:collection> in the next (n-1) files
  3. Have to remove only <?xml version="1.0" encoding="UTF-8" ?><ns0:collection xmlns:ns0="http://www.nwl.co.uk/BillPrintExtractService/1.0"> in the last file and merge all of them together

I have tried using sed command to process first file which is not reulting anything . emrged.xml is empty. sed '/</ns0:collection>/d' $file1 > merged.xml

Any suggestions?

My file contains data which is not well idented. Say like:

<?xml version="1.0" encoding="UTF-8" ?><ns0:collection
xmlns:ns0="http://www.nwl.co.uk/BillPrintExtractService/1.0"><Record>
.
.</Record></ns0:collection>

I have to marge file N number of such files and create one file. So I need the following to be done:

  1. I need to remove only </ns0:collection> closing tag from the first file
  2. remove both <?xml version="1.0" encoding="UTF-8" ?><ns0:collection xmlns:ns0="http://www.nwl.co.uk/BillPrintExtractService/1.0"> and </ns0:collection> in the next (n-1) files
  3. Have to remove only <?xml version="1.0" encoding="UTF-8" ?><ns0:collection xmlns:ns0="http://www.nwl.co.uk/BillPrintExtractService/1.0"> in the last file and merge all of them together

I have tried using sed command to process first file which is not resulting anything, "merged.xml" is empty.

sed '/<\/ns0:collection>/d' $file1 > merged.xml

Any suggestions?

Source Link
Loading