I use sed to customize LXC container configuration files from the LXC host. That works well so far. When adjusting comment headers (hostname and date), there are aesthetic problems with the width of the headers, since when the hostname with different lengths are replaced, the total width of the heather is not automatically compensated for at the end.
in my example the string SERVER should be replaced.
############################
# RSYSLOG Konfiguration #
# SERVER:/etc/rsyslog.conf #
# t12@RMS 2020-03-23 #
############################
############################
# RSYSLOG Konfiguration #
# gersrv:/etc/rsyslog.conf #
# t12@RMS 2020-04-23 #
############################
############################
# RSYSLOG Konfiguration #
# sv4:/etc/rsyslog.conf #
# t12@RMS 2020-06-23 #
############################
How can I get this with sed? Or do I need awk?
sed -i "s/SERVER/${servername}/g" /path to container/etc/rsyslog.conf