在bash
剧本我创建另一个bash
脚本启动的程序:从另一个脚本编写bash脚本在文字模式
$optionsfile="options.conf"
tee "launch-script.sh" > /dev/null <<EOF
#!/bin/bash
bash $binFile `cat $optionsfile` &
EOF
我想输出脚本launch-script.sh
是这样的:
#!/bin/bash
bash $binFile `cat options.conf` &
所以我想让脚本扩大$optionsfile
,但不要执行cat
命令。 现在我越来越:
#!/bin/bash
bash $binFile -ops1 -ops2 -ops3 &
是否有可能实现这一目标?我做错了什么?
编辑:
使用的答案和注释到目前为止,我发现了更好的解决方案将使用转义:
$optionsfile="options.conf"
tee "launch-script.sh" > /dev/null <<EOF
#!/bin/bash
bash $binFile \$(< $optionsfile) &
EOF
更好地从heredoc中删除前导空格:如果您要使用shebang功能,'#!'必须是文件的前2个字符。 – 2015-03-13 13:28:36
请注意,特定于bash的'$(
2015-03-13 13:29:23