Hope someone is able to point me in the right direction here. When I'm passing two variables in sed it no longer seems to recognize the input, and therefore will not replace the string I am looking for.
Could someone please look over my syntax?
Lets assume here that
$netmask1="/24"
$ipaddrs="192.168.0.2 192.168.0.3
astringb=$(grep -m 1 addresses /etc/netplan/01-netcfg.yaml)
astringa=${astringb:0:-1}
ipaddrs=$(echo $ipaddrs | sed "s| |$netmask1\,|g")
sed "s|$astringb|$astringa$ipaddrs$netmask1\]|g" /etc/netplan/01-netcfg.yaml
As soon as I pass variable $astringb to sed it is no longer able to identfy said string in my netplan config file. If I replace this variable with any actual text in this file it'll recognize and replace immediately.
Would appreciate any help.