开发者

Get a file content in Bash after expanding its variables

开发者 https://www.devze.com 2023-03-14 09:14 出处:网络
cat file $VAR cat script开发者_如何学Go #!/bin/bash CONTENT=$(<file) echo $CONTENT ./script $VAR I\'d like to get the variable\'s actual value, not \"$VAR\". How to get a weaker quoting? M

cat file

$VAR

cat script开发者_如何学Go

#!/bin/bash
CONTENT=$(<file)
echo $CONTENT

./script

$VAR

I'd like to get the variable's actual value, not "$VAR". How to get a weaker quoting? Many thanks!


This should do it:

CONTENT=$(eval echo -e `<file`)
0

精彩评论

暂无评论...
验证码 换一张
取 消