Results 1 to 4 of 4
I am trying to use the sed command but i am facing a problem when trying to replace a string containing a slash "/"
for eg:
sed '/LABEL=//s// LABEL=/ elevator=deadline/g' ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-07-2005 #1Linux Newbie
- Join Date
- May 2005
- Location
- Chennai,TamilNadu, India
- Posts
- 141
sed command
I am trying to use the sed command but i am facing a problem when trying to replace a string containing a slash "/"
for eg:
sed '/LABEL=//s// LABEL=/ elevator=deadline/g' $GRUB > $GRUBTEMP
if u notice i am trying to replace the word "LABEL=/" with "LABEL=/ elevator=deadline"
but since the slash character comes at the end of the character it is showing an error.
is there any way of trying to interpret the slash character as part of the word????
if so i would like to know
Since i implemented this without sed by doing a round about method of reading the whole file and doing this
any one has any ideas?
I would also like to know how to append a text to the end of a particular line using sed? i tried the a\ option but it showed me an error
sed '/PATTERN/a\
APPENDED LINE
'
This show i wrote it. the error i got was the the 'A' character in the appended line is not a command...
- 10-07-2005 #2
1. Try using a different delimiter than /:
or try escaping / with a '\'Code:sed s:foo:bar:
2. Enclose the "APPENDED TEXT" in quotes
- 10-09-2005 #3Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
Er, the APPENDED TEXT is already in quotes (single ones). Did you leave a space after the a\ - that would cause an error. The backslash has to be the last character on the line.
- 10-09-2005 #4Linux Newbie
- Join Date
- May 2005
- Location
- Chennai,TamilNadu, India
- Posts
- 141
yes it worked for me now.
i just gave the single quotes and i checked with out the space.
thanks


Reply With Quote
