[Solved] echo not updating double quotes in output

Hi ,

I have a script to update firefox proxy. But the echo is not updating the double quotes.

paste /home/names.txt /home/ip.txt | while read i j
do
mkdir $i
echo "user_pref("network.proxy.http", "$j");" >> /home/$i/prefs.js
echo "user_pref("network.proxy.http_port", 8080);" >> /home/$i/prefs.js
echo "user_pref("network.proxy.type", 1);" >> /home/$i/prefs.js
done

I am getting output

user_pref(network.proxy.http, 202.203.1.102);
user_pref(network.proxy.http_port, 8080);
user_pref(network.proxy.type, 1);

I need below format

user_pref("network.proxy.http", "202.203.1.102");
user_pref("network.proxy.http_port", 8080);
user_pref("network.proxy.type", 1);

Use backslash to escape the quotes you need to be present in your output

echo "user_pref(\"network.proxy.http\", \"$j\");"

You have to escape the double quotes that you want to preserve in echo output, like this:

echo "user_pref(\"network.proxy.http\", \"$j\");"
1 Like

Thanks. It worked perfect