sed calls shell variables and replaces entire lines containing keywords

#!/bin/bash
##
##
##
FILEPATH=/etc/hosts
SVNAME = a.abc.com
NEWIP = 1.1 . 1.1

sed -i 's/^.*'$SVNAME'.*$/'$NEWIP' '$SVNAME'/' $FILEPATH
## Line contains "SVNAME" parameter, replace entire line

 

Guess you like

Origin www.cnblogs.com/itbox/p/12687228.html