And yes i understand that because of the <br/> only my sed is not functioning.
Well, there is a basic technique you might want to learn: escaping. That means: in some programs (here: sed, but the same goes for the shell too) certain characters (here: the "/") have a special meaning. We need a way to have them treated as normal characters, with their special meaning removed, sometimes.
If you want to use "/" as part of the search- and/or replacement string you will have to solve this, because changing i.e. "bla/blub" to "something/else" is not going to work this way. sed simply won't know what is part of the command and what is part of the strings to work on:
Fortunately there is a device - in fact two of them - you can use. The first is to change seds special character: every character following the "s" command will be used, the only requirement is you have to use it consistently. To use "/" as a delimiter is just convention, not part of the syntax. The following two lines are equivalent and will both work:
The problem with this is that it shifts the problem only around: now you replaced "/" with another character you will have to worry about. Here is the definitive solution for that, more work, but final: you prepend the character in question with a "\". This will tell sed to not interpret the following character but take it literally:
Notice, that this works with "\" too - a "\\" will be interpreted as a literal backslash! You can even automatically "sedify" your variables before feeding them to sed. Try the following:
The application of this is left as an exercise to the interested reader. ;-))
Hi bakunin, that was an neat and clear explanation, really appreciate your help.
But am not that good in sed, so some how i have manged to understand whats the sed is doing in ur command.
But, still am getting error that it cannot be parsed to sed. .
Based on the If loop,
sed: Function s/searchstring/This is first line.<br />This is second line.<br />This is third line./g cannot be parsed.
Modification as per your suggestion :
Please let me know what mistake am doing ?
---------- Post updated at 08:18 AM ---------- Previous update was at 07:22 AM ----------
Thanks Scrutinizer, That helps and fixed the issue as well perfectly. But am not able to find your post online, i got the mail, but am not able to find it here. I really want to thank you.
It may sound little weird, but am not able to see your reply.
I really appreciate the help from Scott and Scrutinizer.
Last edited by scott_cog; 11-01-2013 at 11:09 AM..
Hello,
I have written a command n shell script :
srvctl relocate service -d t1 -s s1 -i i1 -t t1 -f
If the above command executes successfully without error I need to echo
"Service relocated successfully
and If it errors out I need to trap the errors in a file and also need to make... (1 Reply)
Hello,
I have a very basic script
#!/usr/bin/ksh
while
print ' '
print ' 1. View Command History '
print ' 2. List files in current Directory '
read opt'?Enter Option> ' ;do
if ;then
fc -l
fi
#
if ;then
ls -la
I want to... (10 Replies)
Hi,
I try to write script and echo two command at the same line .
echo "A"
echo "B"
How can I pipe above two command at the same line in text file .
So, in the output text file , you can see below ???
A B
not
A
B
Any sugggestion ??? (4 Replies)
Hello,
I'm writing some bash scripts and I'm trying to get an echo command and the output of another command to display on the same line. For example:
I want to run
echo "Operating System: " unameand have it displayed as
Operating System: Darwin
Thanks for your help! (7 Replies)
Hi
I want to display "echo command value in loop" in single line. My requirement is to show the input file (test_1.txt) like the output file (test_2.txt) given below.
Input file :test_1.txt
a1|b1|4|5
a1|b1|42|9
a2|b2|32|25
a1|b1|2|5
a3|b3|4|8
a2|b2|14|6
Output file:test_2.txt... (2 Replies)
Hi
i would like disply the new line in echo command.
i have input like:
echo " X1 02:12:13 X2 03:02:12 "
out put:
X1 02:12:13
X2 03:02:12
can you tell how can use new line option in echo command. (5 Replies)
I have script like
echo -n FINISHED FEXP: ${TABLE2EXP}
echo $STATUS
I want the output of both the echo statement in one line
How can i do this (3 Replies)
hello,
i have a listing (let say ABC) consists of the below:
:
public database link
public synonym
role
rollback segment
:
when i run the below for loop,
for i in `more ABC`
do
echo "$i"
done
it gives me,
:
public
database (4 Replies)