简体   繁体   English

将环境变量值导入文件 Shell 脚本

[英]Import Environment Variable value into a file Shell Script

I have an 12.sh file with the below code我有一个带有以下代码的 12.sh 文件

cat > /home/12.txt << "EOF"
[Unit]
${OUTPUT}
EOF

OUTPUT is an environment variable i want to import its value into the 12.txt file when i execute 12.sh file OUTPUT 是一个环境变量,我想在执行 12.sh 文件时将其值导入 12.txt 文件

Any one can tell how to do, Thanks in advance任何人都可以告诉怎么做,提前谢谢

You don't need to use cat, just echo the data required are redirect the output to the file您不需要使用 cat,只需回显所需的数据即可将 output 重定向到文件

echo -e "[Unit]\n$OUTPUT" > /home/12.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM