trying to write a new sed command that will insert new lines before another line.
the code i have tried and is failing is:
sudo sed -i '/# onlynet=ipv4/i echo "rpcallowip='$WebInternalIP'\n";\necho "rpcallowip='$DBInternalIP'\n";\necho "rpcallowip='$StratumInternalIP'\n";' $STORAGE_ROOT/yiimp/site/web/yaamp/modules/site/coin_form.phpThe new lines need to read:
echo "rpcallowip=$Variable\n"; example, echo "rpcallowip=127.0.0.1\n";the code above is producing the following result:
echo "rpcallowip=10.0.0.3
";So it is seeing the \n as another new line instead of part of the line.
1 Answer
As noted in the GNU Sed manual for the i\text command:
Escape sequences in text are processed, so you should use \ in text to print a single backslash.
Hence to insert the literal sequence \n, you will need to use \\n