Answer the question
In order to leave comments, you need to log in
How to replace a string with double quotes and a variable in sed?
Hello dear experts.
It is required using sed to replace the line, and even with a variable that could not beat for an hour, it just does not change :)
The code is something like this:
#!/bin/bash
IP=`wget -qO- someurl.com`
GMT=`wget -qO- someurl.com?$IP`
OLD="TimeZone="600""
REP="TimeZone="$GMT""
sed -i "s/$OLD/$REP/" test.txt
sed -i "s|TimeZone=\x22600\x22|TimeZone=\x22$GMT\x22|g" test.txt
<TimeConfig TimeMode="NTP" TimeZone="600">
TimeZone=
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question