I'm trying to use the following command:
awk '/dev-api2\.company-private/{p=NR} p && NR==p+2 && /^HostName/{
$0="HostName 1.1.1.1"; p=0} 1' ~/.ssh/config > $$.tmp && mv $$.tmp ~/.ssh/config
Taken from this SO question.
Now I would like to replace the following:
dev-api2 with $shn
1.1.1.1 with $privateip
But now when I run the awk command it does nothing.
These are the values of the variables:
shn=dev-api2
privateip=3.3.3.3