引用环境变量替换文字模版

最后更新于:2022-04-02 03:47:56

[TOC] ## 方式一: 使用 envsubst ``` > export username=idcpj > cat a.bash echo "pwd is ${PWD}" echo "username is ${username}" > cat a.bash| envsubst > b.bash echo "pwd is /Users/idcpj/Downloads" echo "username is idcpj" ``` ## 方式二:纯原生 ``` > export username=idcpj > cat c.bash cat > d.bash << EOF echo "pwd is ${PWD}" echo "username is ${username}" EOF > bash c.bash > cat d.bash echo "pwd is /Users/idcpj/Downloads" echo "username is idcpj" ```
';