Envsubst
Jump to navigation
Jump to search
Use bash to replace variables in host
https://serverfault.com/questions/287688/templating-with-linux-in-a-shell-script
Example template file apache.tmpl: <VirtualHost *:${PORT}> ServerName ${SERVER_NAME} ServerAlias ${SERVER_ALIAS} DocumentRoot "${DOCUMENT_ROOT}" </VirtualHost> Run envsubst and output result to new file my_apache_site.conf: export PORT="443" export SERVER_NAME="example.com" export SERVER_ALIAS="www.example.com" export DOCUMENT_ROOT="/var/www/html/" envsubst < apache.tmpl > my_apache_site.conf Output: <VirtualHost *:443> ServerName example.com ServerAlias www.example.com DocumentRoot "/var/www/html/" </VirtualHost>