I am trying to replace the variable in the file after the particular match string. It is being replaced if i hardcode the value and with use of "&" with sed.
sed -e "s/URL./& http:\\localhost:7223/g"
But when am trying to pass the variable it is failing. I tried multiple options mentioned below.
sed -e "s/URL./& $url/g"
or
sed -e "s/URL./&\ $url/g"
or
sed -e "s/URL./&\ |$url/g"
Error
sed: -e expression #1, char 16: unknown option to `s'
Can I anyone suggest if sed replacement support variable with "&".
I have tried that multiple time but getting the same issue.
Pasting my script.
#! /bin/bash
HSFILE=/home/user/Temp/Test/Log/Server2/Components.txt
num=1
while IFS="|" read url port
do
echo "URL is $url Port is $port"
< Monitor_Template.txt sed -e "s/HawkController./& $url/g" > "/home/user/Temp/Test/Log/Server2/Server1/Monitor_Template_$num.txt"
num=$(($num+1))
echo "Welcome"
done < $HSFILE