我需要在 bash 脚本中读入一个 php 模板文件,然后替换模板中的一些变量(可以是任何东西,比如$(variable)
),最后将整个内容输出到一个新文件中。
我原本有
stuff=$stuff bash templatefile > newfile
对于非 PHP 文件
cat <<END
//stuff
END
但我的 php 模板文件看起来像
#!/usr/bin/php
<?php
//lots of php variables, so can't use bash variables that have the same $ prefix
?>
因为 PHP 也像 bash 一样为它的变量使用 $ 前缀,所以我不能轻易地传入参数。我该怎么办?