Basically I have a situation where I frequently need to modify my hosts file to access different servers at my workplace. In an attempt to automate the process. I've been trying to use
sed to make the changes I need. Basically I am trying to preserve the whole line for some IP's and comment out other IP's.
For IP's that start with
10.4. To uncomment via
sed, I've attempted this
sed -i '/#10\.4\..*/c\10\.4\..*' /etc/hosts
which replaced all the matching lines with
10.4..* instead of preserving the whole line. I've also attempted this in an attempt to use a group/match:
sed -i '/#10\.4\.(.*)/c\10\.4\.\1' /etc/hosts
but this just silently fails without making any changes at all.
What am I doing wrong?