sed: find and replace string but not super-string -
i have file env
looks like
....
legacy_database_server=10.0.0.1 server=10.1.1.1
and here sed command:
sed -e "s/server=.*/server=$instance_ip/g;n" $env_file > $env_file.tmp && mv $env_file.tmp $env_file
the problem sed
replacing legacy_database_server
not want. want server
replaced.
(legacy_database_server super string of server , want replace server)
what missing?
presumably, want make sure sed knows "server" @ beginning of line:
sed -e "s/^server=.*/server=$instance_ip/g;n" $env_file > $env_file.tmp && mv $env_file.tmp $env_file
Comments
Post a Comment