Ignore escape sequence in sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ignore escape sequence in sed
# 1  
Old 06-01-2013
Ignore escape sequence in sed

Friends,

In the file i am having more then 100 lines like,

File1 had the values like this:
Code:
 
#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:
Code:
 
#Example EAST.SERVER_01=http://yahoo.com
EAST.SERVER_01=http\://google.com
WEST.SERVER_01=http://google1.com

After the running the sed command File1 should be:

Code:
 
#Example East.server_01=EAST.SERVER_01
East.server_01=http\://google.com
West.server_01=http://google1.com


But i am getting the value like below in File1:
Code:
 
#Example East.server_01=EAST.SERVER_01
East.server_01=http://google.com
West.server_01=http://google1.com



If the line had Escape sequence like (\) in Url it is ignoring in output, but i need that (\) for my Application configuration.

Similarly If the line start with (#) we need to ignore the line, with out sed operation

Could you please check on this,

Thanks in Advance
JB

Last edited by jothi basu; 06-01-2013 at 08:25 AM..
# 2  
Old 06-01-2013
Quote:
Originally Posted by jothi basu
Friends,

In the file i am having more then 100 lines like,

Code:
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
EAST.SERVER_01=http\://google.com
WEST.SERVER_01=http://google1.com
 
 After the running the sed command File1 should be:
 #Example East.server_01=EAST.SERVER_01
East.server_01=http\://google.com
West.server_01=http://google1.com
 
But i am getting the value like below in File1:
#Example East.server_01=EAST.SERVER_01
East.server_01=http://google.com
West.server_01=http://google1.com




If the line had Escape sequence like (\) in Url it is ignoring in output, but i need that (\) for my Application configuration.

Similarly If the line start with (#) we need to ignore the line, with out sed operation

Could you please check on this,

Thanks in Advance
JB
I don't understand!

First, please use code tags around the file contents; not around the contents AND the descriptions of the contents.

Second, are you saying that your input files contain code to change font and color; or is that just something you added to confuse us? Do we really have to parse the font and color changes within these lines so we not only copy changes to text but also possible changes to font, color, boldness, and italicization?

Third, you say that comment lines are to be ignored, but instead of ignoring them in the output, you add a space to the start of comment lines??? What do you mean by ignore: Do not change comment lines, or delete comment lines?

Fourth why would you limit us to using sed for this? Your specification of what is supposed to happen is ambiguous, but it seems that awk would be a much better tool for this job.
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 06-01-2013
Could pls check now...

---------- Post updated at 04:26 PM ---------- Previous update was at 04:26 PM ----------

Quote:
Originally Posted by Don Cragun
I don't understand!

First, please use code tags around the file contents; not around the contents AND the descriptions of the contents.

Second, are you saying that your input files contain code to change font and color; or is that just something you added to confuse us? Do we really have to parse the font and color changes within these lines so we not only copy changes to text but also possible changes to font, color, boldness, and italicization?

Third, you say that comment lines are to be ignored, but instead of ignoring them in the output, you add a space to the start of comment lines??? What do you mean by ignore: Do not change comment lines, or delete comment lines?

Fourth why would you limit us to using sed for this? Your specification of what is supposed to happen is ambiguous, but it seems that awk would be a much better tool for this job.
Could pls check now..
# 4  
Old 06-01-2013
Quote:
Originally Posted by jothi basu
Friends,

In the file i am having more then 100 lines like,

File1 had the values like this:
Code:
 
#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:
Code:
 
#Example EAST.SERVER_01=http://yahoo.com
EAST.SERVER_01=http\://google.com
WEST.SERVER_01=http://google1.com

After the running the sed command File1 should be:

Code:
 
#Example East.server_01=EAST.SERVER_01
East.server_01=http\://google.com
West.server_01=http://google1.com


But i am getting the value like below in File1:
Code:
 
#Example East.server_01=EAST.SERVER_01
East.server_01=http://google.com
West.server_01=http://google1.com



If the line had Escape sequence like (\) in Url it is ignoring in output, but i need that (\) for my Application configuration.

Similarly If the line start with (#) we need to ignore the line, with out sed operation

Could you please check on this,

Thanks in Advance
JB
Thank you for fixing the code tags.

Please answer the remaining questions:
  1. Are you saying that your input files contain code to change font and color; or is that just something you added to confuse us? Do we really have to parse the font and color changes within these lines so we not only copy changes to text but also possible changes to font, color, boldness, and italicization?
  2. What do you mean by ignore comment lines?
  3. Why would you limit us to using sed for this? Your specification of what is supposed to happen is ambiguous, but it seems that awk would be a much better tool for this job.
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

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. sed -e "s/xmlns=http://www.abc.com/integration/services/testtemplate1//g" Orginal.xml... (3 Replies)
Discussion started by: jimmyb
3 Replies

3. Solaris

Escape Sequence for Capital Letters Input at Shell Not Working

Hello, I am running Solaris 8. When issuing the command "stty lcase" all text which is output to the terminal are capitalized. Letters that are supposed to be capitals are preceded by a backslash during output. All text which is input is converted to lower case. This is the expected behaviour... (5 Replies)
Discussion started by: rstor
5 Replies

4. 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

5. 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

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