Shell script -adding XML tag to next line [on hold] The Next CEO of Stack OverflowHow to find and replace a particular string in a specific lineMaking A Shell Script To Write To XML FileHow to add an attribute in a tag in XML file by command-line?How to remove a line from a tag in shell script?alter a line and remove tag using perl from xml file?Shell Script: Want to delete two consecutive lines matching pattern from specific lineShell Script to extract the tag valueInsert custom XML tag into a XML file in a bash scriptAdding Numerical Suffixes to Tag-Names to Distinguish XML ElementsXML command line (shell script) manipulation
What happens if you roll doubles 3 times then land on "Go to jail?"
How to get regions to plot as graphics
Was a professor correct to chastise me for writing "Prof. X" rather than "Professor X"?
How can I quit an app using Terminal?
Anatomically Correct Strange Women In Ponds Distributing Swords
Increase performance creating Mandelbrot set in python
Can I equip Skullclamp on a creature I am sacrificing?
Go Pregnant or Go Home
Natural language into sentence logic
WOW air has ceased operation, can I get my tickets refunded?
Horror movie/show or scene where a horse creature opens its mouth really wide and devours a man in a stables
Should I tutor a student who I know has cheated on their homework?
Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?
How to write papers efficiently when English isn't my first language?
Can a caster that cast Polymorph on themselves stop concentrating at any point even if their Int is low?
What is the purpose of the Evocation wizard's Potent Cantrip feature?
Are there languages with no euphemisms?
How can I get through very long and very dry, but also very useful technical documents when learning a new tool?
Why here is plural "We went to the movies last night."
If the heap is initialized for security, then why is the stack uninitialized?
What can we do to stop prior company from asking us questions?
Term for the "extreme-extension" version of a straw man fallacy?
How to safely derail a train during transit?
How do I solve this limit?
Shell script -adding XML tag to next line [on hold]
The Next CEO of Stack OverflowHow to find and replace a particular string in a specific lineMaking A Shell Script To Write To XML FileHow to add an attribute in a tag in XML file by command-line?How to remove a line from a tag in shell script?alter a line and remove tag using perl from xml file?Shell Script: Want to delete two consecutive lines matching pattern from specific lineShell Script to extract the tag valueInsert custom XML tag into a XML file in a bash scriptAdding Numerical Suffixes to Tag-Names to Distinguish XML ElementsXML command line (shell script) manipulation
I am creating an XML file using shell script and output is coming as below.I want the <type>
tag to come in new line
<?xml version="1.0" encoding="ABCCD"><type><members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type><members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
<members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
text-processing scripting xml
New contributor
put on hold as unclear what you're asking by Stephen Kitt, jimmij, nwildner, roaima, Mr Shunz 17 hours ago
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I am creating an XML file using shell script and output is coming as below.I want the <type>
tag to come in new line
<?xml version="1.0" encoding="ABCCD"><type><members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type><members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
<members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
text-processing scripting xml
New contributor
put on hold as unclear what you're asking by Stephen Kitt, jimmij, nwildner, roaima, Mr Shunz 17 hours ago
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
4
An XML parser would not care about the newline. Also, if you would want help with fixing an existing script, then it would be helpful to see the code of that script.
– Kusalananda♦
yesterday
add a comment |
I am creating an XML file using shell script and output is coming as below.I want the <type>
tag to come in new line
<?xml version="1.0" encoding="ABCCD"><type><members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type><members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
<members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
text-processing scripting xml
New contributor
I am creating an XML file using shell script and output is coming as below.I want the <type>
tag to come in new line
<?xml version="1.0" encoding="ABCCD"><type><members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type><members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
<members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
text-processing scripting xml
text-processing scripting xml
New contributor
New contributor
edited yesterday
Jeff Schaller♦
44.1k1161142
44.1k1161142
New contributor
asked yesterday
user343859user343859
1
1
New contributor
New contributor
put on hold as unclear what you're asking by Stephen Kitt, jimmij, nwildner, roaima, Mr Shunz 17 hours ago
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as unclear what you're asking by Stephen Kitt, jimmij, nwildner, roaima, Mr Shunz 17 hours ago
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
4
An XML parser would not care about the newline. Also, if you would want help with fixing an existing script, then it would be helpful to see the code of that script.
– Kusalananda♦
yesterday
add a comment |
4
An XML parser would not care about the newline. Also, if you would want help with fixing an existing script, then it would be helpful to see the code of that script.
– Kusalananda♦
yesterday
4
4
An XML parser would not care about the newline. Also, if you would want help with fixing an existing script, then it would be helpful to see the code of that script.
– Kusalananda♦
yesterday
An XML parser would not care about the newline. Also, if you would want help with fixing an existing script, then it would be helpful to see the code of that script.
– Kusalananda♦
yesterday
add a comment |
1 Answer
1
active
oldest
votes
Try this,
sed 's/><type>/>n<type>/g;s/<type></<type>n</g' file.xml
will search for the pattern ><type>
then add a new line before the <type>
and search for the pattern <type><
then add a new line after of <type>
.
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
<members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
if the output is OK. use -i
option in sed to do inline edit.
1
yes working.Thanks
– user343859
yesterday
Now the output come like this as below.I don't want the 2 lines between </type><type> ...... <?xml version="1.0" encoding="ABCCD"> <type> <members>ABC</members> <members>ABC</members> <name>ABC</name> </type> <type> <members>system</members> <name>ABC</name> </type> <version>XYZ</version> </Package>
– user343859
yesterday
@user343859 try my update
– msp9011
yesterday
can u update the same in question?
– msp9011
yesterday
Thanks.....sed 's/<type>/n<type>n/g' is working .Spacing is not an issue now
– user343859
yesterday
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try this,
sed 's/><type>/>n<type>/g;s/<type></<type>n</g' file.xml
will search for the pattern ><type>
then add a new line before the <type>
and search for the pattern <type><
then add a new line after of <type>
.
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
<members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
if the output is OK. use -i
option in sed to do inline edit.
1
yes working.Thanks
– user343859
yesterday
Now the output come like this as below.I don't want the 2 lines between </type><type> ...... <?xml version="1.0" encoding="ABCCD"> <type> <members>ABC</members> <members>ABC</members> <name>ABC</name> </type> <type> <members>system</members> <name>ABC</name> </type> <version>XYZ</version> </Package>
– user343859
yesterday
@user343859 try my update
– msp9011
yesterday
can u update the same in question?
– msp9011
yesterday
Thanks.....sed 's/<type>/n<type>n/g' is working .Spacing is not an issue now
– user343859
yesterday
add a comment |
Try this,
sed 's/><type>/>n<type>/g;s/<type></<type>n</g' file.xml
will search for the pattern ><type>
then add a new line before the <type>
and search for the pattern <type><
then add a new line after of <type>
.
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
<members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
if the output is OK. use -i
option in sed to do inline edit.
1
yes working.Thanks
– user343859
yesterday
Now the output come like this as below.I don't want the 2 lines between </type><type> ...... <?xml version="1.0" encoding="ABCCD"> <type> <members>ABC</members> <members>ABC</members> <name>ABC</name> </type> <type> <members>system</members> <name>ABC</name> </type> <version>XYZ</version> </Package>
– user343859
yesterday
@user343859 try my update
– msp9011
yesterday
can u update the same in question?
– msp9011
yesterday
Thanks.....sed 's/<type>/n<type>n/g' is working .Spacing is not an issue now
– user343859
yesterday
add a comment |
Try this,
sed 's/><type>/>n<type>/g;s/<type></<type>n</g' file.xml
will search for the pattern ><type>
then add a new line before the <type>
and search for the pattern <type><
then add a new line after of <type>
.
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
<members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
if the output is OK. use -i
option in sed to do inline edit.
Try this,
sed 's/><type>/>n<type>/g;s/<type></<type>n</g' file.xml
will search for the pattern ><type>
then add a new line before the <type>
and search for the pattern <type><
then add a new line after of <type>
.
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
<members>system</members>
<name>ABC</name>
</type>
<version>XYZ</version>
</Package>
<?xml version="1.0" encoding="ABCCD">
<type>
<members>ABC</members>
<members>ABC</members>
<name>ABC</name>
</type>
<type>
if the output is OK. use -i
option in sed to do inline edit.
edited yesterday
answered yesterday
msp9011msp9011
4,54244167
4,54244167
1
yes working.Thanks
– user343859
yesterday
Now the output come like this as below.I don't want the 2 lines between </type><type> ...... <?xml version="1.0" encoding="ABCCD"> <type> <members>ABC</members> <members>ABC</members> <name>ABC</name> </type> <type> <members>system</members> <name>ABC</name> </type> <version>XYZ</version> </Package>
– user343859
yesterday
@user343859 try my update
– msp9011
yesterday
can u update the same in question?
– msp9011
yesterday
Thanks.....sed 's/<type>/n<type>n/g' is working .Spacing is not an issue now
– user343859
yesterday
add a comment |
1
yes working.Thanks
– user343859
yesterday
Now the output come like this as below.I don't want the 2 lines between </type><type> ...... <?xml version="1.0" encoding="ABCCD"> <type> <members>ABC</members> <members>ABC</members> <name>ABC</name> </type> <type> <members>system</members> <name>ABC</name> </type> <version>XYZ</version> </Package>
– user343859
yesterday
@user343859 try my update
– msp9011
yesterday
can u update the same in question?
– msp9011
yesterday
Thanks.....sed 's/<type>/n<type>n/g' is working .Spacing is not an issue now
– user343859
yesterday
1
1
yes working.Thanks
– user343859
yesterday
yes working.Thanks
– user343859
yesterday
Now the output come like this as below.I don't want the 2 lines between </type><type> ...... <?xml version="1.0" encoding="ABCCD"> <type> <members>ABC</members> <members>ABC</members> <name>ABC</name> </type> <type> <members>system</members> <name>ABC</name> </type> <version>XYZ</version> </Package>
– user343859
yesterday
Now the output come like this as below.I don't want the 2 lines between </type><type> ...... <?xml version="1.0" encoding="ABCCD"> <type> <members>ABC</members> <members>ABC</members> <name>ABC</name> </type> <type> <members>system</members> <name>ABC</name> </type> <version>XYZ</version> </Package>
– user343859
yesterday
@user343859 try my update
– msp9011
yesterday
@user343859 try my update
– msp9011
yesterday
can u update the same in question?
– msp9011
yesterday
can u update the same in question?
– msp9011
yesterday
Thanks.....sed 's/<type>/n<type>n/g' is working .Spacing is not an issue now
– user343859
yesterday
Thanks.....sed 's/<type>/n<type>n/g' is working .Spacing is not an issue now
– user343859
yesterday
add a comment |
4
An XML parser would not care about the newline. Also, if you would want help with fixing an existing script, then it would be helpful to see the code of that script.
– Kusalananda♦
yesterday