JSW
  • 🏠 首页
  • › 日志
  • › 正文

Bash: envsubst

将环境变量传递给文件

🕐 2023-10-11 13:35:23

welcome.txt

This is $FOO and this $BAR

usage

export FOO=foo export BAR=bar
# 全量替换
envsubst < welcome.txt
This is foo and this bar

# 部分替换
envsubst '$FOO' < welcome.txt
This is foo and this $BAR

# 多个变量
envsubst '$FOO,$BAR' < welcome.txt
This is foo and this bar

参考

  • https://man7.org/linux/man-pages/man1/envsubst.1.html
  • https://www.baeldung.com/linux/envsubst-command
JSW
日志 笔记 代码 作品 关于
🐱 © 2021-2026 鄂ICP备2023002340号-1
    JSW
  • 导航菜单
  • 日志
  • 笔记
  • 经验
  • 代码
  • 作品
  • 相册
  • 专辑
  • 关于
  • 链接
  • 🐱 GitHub