I have a problem. I want to write an IP into a file with
sed -i 's/.*#source*/&\n'"$newsource"'/' file
This is because you must either escape your
/, or change the
sed separator to something else:
newsource=18.104.22.168\/24 sed -i 's/.*#source*/&\n'"$newsource"'/' file
newsource=22.214.171.124/24 sed -i 's~.*#source*~&\n'"$newsource"'~' file
Share and enjoy.