Escape Sequence Overide in XML file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Escape Sequence Overide in XML file
# 1  
Old 08-26-2013
Escape Sequence Overide in XML file

Hi

I am try to use sed to remove decleration information from an XML file however their are special characters in the string and sed is not able to parse it . I am using the following commond.


Code:
sed -e "s/xmlns=http://www.abc.com/integration/services/testtemplate1//g" Orginal.xml >output.xml

I want to remove the following information
Code:
xmlns=http://www.abc.com/integration/services/testtemplate1

I am getting the error message


Code:
sed: 0602-404 Function s/xmlns=http://www.abc.com/integration/services/testtemplate1//g cannot be parsed

However the sed is not working.

Any suggestion please

Last edited by Don Cragun; 08-26-2013 at 11:18 PM..
# 2  
Old 08-26-2013
When the pattern you're trying to replace contains slash (/) characters, you have to use something other than slash as the delimiter in the sed substitute command or escape all of the slash characters in the pattern. For this example, you could try using the pipe symbol (|) as the delimiter:
Code:
sed -e "s|xmlns=http://www.abc.com/integration/services/testtemplate1||g" Orginal.xml >output.xml

This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 08-26-2013
Hi Don
Thanks a lot for your reply .I have one more issue their are qoutes also how do I take care of those its like


Code:
 
sed -e "s|xmlns="123//abc/integration/"||g" Orginal.xml >output.xml

How do I handle these

---------- Post updated at 10:51 PM ---------- Previous update was at 10:43 PM ----------

I understand If I use single qoutes I will be able to handle it but I want to pass the string as a variable and when I use single qoutes it may not expand the variable
# 4  
Old 08-27-2013
Quote:
Originally Posted by jimmyb
Hi Don
Thanks a lot for your reply .I have one more issue their are qoutes also how do I take care of those its like


Code:
 
sed -e "s|xmlns="123//abc/integration/"||g" Orginal.xml >output.xml

How do I handle these

---------- Post updated at 10:51 PM ---------- Previous update was at 10:43 PM ----------

I understand If I use single qoutes I will be able to handle it but I want to pass the string as a variable and when I use single qoutes it may not expand the variable
You are correct in saying that variables will not be expanded when they appear inside single quotes. Since there are no variables in your example I don't know what you're trying to do.

The sed command above will perform the same as any of the following:
Code:
sed -e "s|xmlns=123//abc/integration/||g" Orginal.xml >output.xml
sed -e 's|xmlns='123//abc/integration/'||g' Orginal.xml >output.xml
sed -e 's|xmlns=123//abc/integration/||g' Orginal.xml >output.xml
sed -e s"|"xmlns=123//abc/integration/'||'g Orginal.xml >output.xml

or several million other commands with other combinations of single and double quotes. If you will clearly describe where you want to put a variable and explain what is in the variable, we may be able to help.

If you are hoping to set a shell variable to a string matched by a pattern given in a sed substitute command, the syntax you are using is VERY strange and will not work in that form.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Escape sequence for Function keys - terminfo

Having a doubt on how Function keys are mapped. 1. In my HPUX box my infocmp shows that kf1 (F1 key mapping) is not mapped. But somehow I am able to use an Informix form which requires navigation using F1 keys. vt100-w|vt100-w-am|dec vt100 132 cols (w/advanced video), bce, bw, ccc,... (3 Replies)
Discussion started by: clemansy
3 Replies

2. Shell Programming and Scripting

Ignore escape sequence in sed

Friends, In the file i am having more then 100 lines like, File1 had the values like this: #Example East.server_01=EAST.SERVER_01 East.server_01=EAST.SERVER_01 West.server_01=WEST.SERVER_01 File2 had the values like this: #Example EAST.SERVER_01=http://yahoo.com... (3 Replies)
Discussion started by: jothi basu
3 Replies

3. Red Hat

Grep doesn't understand escape sequence?

I ran the following grep and sed command. grep "\t" emp.txt sed -n '/\t/p' emp.txt grep treated the '\' as to escape t and took the pattern as literal t whereas sed took the pattern as tab. That means , grep doesn't understand escape sequence!!!!!! what to do to make grep... (8 Replies)
Discussion started by: ravisingh
8 Replies

4. Shell Programming and Scripting

Help with escape sequence for '$' symbol in EGREP function

$table is the variable which contains name of the file. Filename may have the special character $. Need to escape $ . Tried below options to escape dollar: \$$table "\$"$table"" what is the escape sequence for egrep function..? Below is the code snippet- my $table; foreach... (3 Replies)
Discussion started by: xylus77
3 Replies

5. Shell Programming and Scripting

How to achieve UTF-8 encoding & URL escape in an xml file?

Is there any i can achieve entity escaping, URL escaping & UTF-8 encoded for the xml generated through shell script? #! /bin/bash echo "<path>" >> file.xml for x in `ls filename*` do echo -e "\t<dir>" >> file.xml echo -e "\t\t<file>$x</file>" >> file.xml... (0 Replies)
Discussion started by: vel4ever
0 Replies

6. Shell Programming and Scripting

Removing Escape Sequence Characters

Hi All, I have added the script command to user profile so that to record the on-screen data.But when i i checked the O/P i could see lot of escape sequence is there way to remove it. (2 Replies)
Discussion started by: cutechaps
2 Replies

7. Shell Programming and Scripting

escape sequence for $

Hi all, I have a requirement where the variable name starts with $, like $Amd=/home/student/test/ How to work wit it? can some one help me, am in gr8 confusion:confused: (5 Replies)
Discussion started by: shreekrishnagd
5 Replies

8. UNIX for Dummies Questions & Answers

Both HOME and INSERT key send same escape sequence on ssh

I couldn't seem to make 'HOME' key work on my remote windows ssh client to a Fedora Core3 server (the home key works perfectly when i'm physically on site.) To my surprise, using control+V it seems that both my home and insert key send the same escape sequence ^So it must be my windows SSH client... (0 Replies)
Discussion started by: grossgermany
0 Replies

9. UNIX for Advanced & Expert Users

want to view the escape sequence

Hi, Is it possible to view the escape sequence in the ascii file. That is I want to see the newlinw character,tab ........ etc Thanks Sweta (4 Replies)
Discussion started by: sweta
4 Replies

10. Shell Programming and Scripting

Escape sequence

Hi, I have got an application through which an user will submit an address like "c:\tuser\abc". This application calls a script and passes the address to the scripts positional parameter say $1. So $1 should contain "c:\tuser\abc", but when $1 is echoed the "\t" and "\a" are interpreted to... (4 Replies)
Discussion started by: puspendu
4 Replies
Login or Register to Ask a Question