Bit of sed help in XML


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bit of sed help in XML
# 1  
Old 07-15-2016
Bit of sed help in XML

Hi all, need some help seeing the bug in my SED

Source XML
Code:
<SMART_FOLDER JOBISN="1" SUB_APPLICATION="PMT-APB" MEMNAME="Job0" JOBNAME="PMT-APB" FOLDER_NAME="PMT-APB">
</SMART_FOLDER>

My SED Command
Code:
sed -e 's/\(<SMART_FOLDER \)\(.*FOLDER_NAME="PMT-APB"\)/\FOLDER_ORDER_METHOD="PCI" \2/' < test.xml

This is what I get
Code:
 FOLDER_ORDER_METHOD="PCI" JOBISN="1" SUB_APPLICATION="PMT-APB" MEMNAME="Job0" JOBNAME="PMT-APB" FOLDER_NAME="PMT-APB">
</SMART_FOLDER>

It keeps stripping the leading <SMART_FOLDER but I can't understand why

---------- Post updated at 05:50 PM ---------- Previous update was at 05:13 PM ----------

Found the problem, I was missing \1 before FOLDER_ORDER_METHOD

Code:
sed -e 's/\(<SMART_FOLDER \)\(.*FOLDER_NAME="PMT-APB"\)/\1FOLDER_ORDER_METHOD="PCI" \2/' < test.xml


Last edited by J-Man; 07-15-2016 at 07:45 PM.. Reason: trim down xml
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Which version of Windows Vista to install with a product key? 32-bit or 64-bit?

Hello everyone. I bought a dell laptop (XPS M1330) online which came without a hard drive. There is a Windows Vista Ultimate OEMAct sticker with product key at the bottom case. I checked dell website (here) for this model and it says this model supports both 32 and 64-bit version of Windows... (4 Replies)
Discussion started by: milhan
4 Replies

2. Shell Programming and Scripting

How to handle 64 bit arithmetic operation at 32 bit compiled perl interpreter?H

Hi, Here is the issue. From the program snippet I have Base: 0x1800000000, Size: 0x3FFE7FFFFFFFF which are of 40 and 56 bits. SO I used use bignum to do the math but summing them up I always failed having correct result. perl interpreter info, perl, v5.8.8 built for... (0 Replies)
Discussion started by: rrd1986
0 Replies

3. Shell Programming and Scripting

Where to find 64-bit based perl module like XML::Parser::Expat?

Q: Where to get a 64 bit Expat.so? I run a perl script and got this error: Can't load '/usr/perl5/vendor_perl/5.8.4/i86pc-solaris-64int/auto/XML/Parser/Expat/Expat.so' for module XML:parser::Expat: ld.so.1:myPerl: fatal:... (0 Replies)
Discussion started by: lilili07
0 Replies

4. Shell Programming and Scripting

How to tell SED to emit output in 8-bit ASCII only?

I have to mangle some "plain ASCII" text file (i.e. 8 bits/characters where the text DOES contain characters like Umlauts and accented characters from the upper 7-bits range, i.e. with hex codes in ). For this I am trying to use SED which I downloaded as part of cygwin package (yes, I am doing... (0 Replies)
Discussion started by: mmo
0 Replies

5. Programming

copying or concatinating string from 1st bit, leaving 0th bit

Hello, If i have 2 strings str1 and str2, i would like to copy/concatenate str2 to str1, from 1st bit leaving the 0th bit. How do i do it? (2 Replies)
Discussion started by: jazz
2 Replies
Login or Register to Ask a Question