Sed not accepting variable in line replacement
Hi Guys,
I'm doing a line replacement operation and sed is not accepting any variable. This is my script ---- i=10.10.10.1 sed '5 c\IPADDR=$i\' test ---- I tried a-lot of variation like using "". None is working. Any suggestions guys |
Try:
Code:
sed "3 c\IPADDR=$i\\" test |
Double quotes are required and the . means any single character so you want to escape it if you exactly want to match the IP address. Starting with the simpler case of not addressing a specific line and substituting the match, does this work:
Code:
i='10\.10\.10\.1' |
Hi Guys,
Thanks sycamorex. That did the trick. Can you tell how it is escaped here. |
Quote:
Code:
$i\" Code:
c\......\ Code:
\\" I hope that makes sense to you:) |
Hello,
Wow.. i never though of that. That makes sense. Thanks sycamorex. |
All times are GMT -5. The time now is 07:45 AM. |