I am completely new to sed script. I studied how to add text to a file, and I managed to get the text that I want to add to the correct line in the file, but cannot find a way to add it to the correct position!
so the line that I have in the text file looks like this:
listen_addresses = 'localhost, 192.0.0.0' # what IP address(es) to listen on;
I want to add an IP so that the line looks like this:
listen_addresses = 'localhost, 192.0.0.0, 192.0.0.0'
Through the trial version and the error, I only have:
sed -i '/listen_addresses/ s/.*/&,192.0.0.0/' testfile
which gives:
listen_addresses = 'localhost, 192.0.0.0'
How can I add it to the right position?
source share