我需要一些幫助,我有一個腳本(script.sh),內容如下:
#!/bin/bash
export name='toto'
file='file.txt'
content=$(cat "file.txt")
echo "$content"
file.txt 內容一些文本:我是 $name
現在,當我運行我的腳本 (script.sh) 時,變數 $name 不會被解釋,我得到了這樣的結果:我是 $name 我想要這樣的結果:我是托托
uj5u.com熱心網友回復:
您可以envsubst為此使用:
content=$(envsubst < "file.txt")
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/329921.html
