sed -i $'/<!--Change here-->/ {r ${TEST_DIRECTORY}/check.html\n d}' "${TEST_DIRECTORY}"/result.html
以上sed文件读取未取实际值${TEST_DIRECTORY}
{r ${TEST_DIRECTORY}/check.html\n d}
但它适用于实际值
{r dir1/dir2/check.html\n d}
答案 0 :(得分:0)
单引号内的变量不会被Bourne shell扩展。改为使用双引号:
sed -i $'/<!--Change here-->/ {r '"${TEST_DIRECTORY}"$'/check.html\n d}' "${TEST_DIRECTORY}"/result.html
答案 1 :(得分:0)
您需要双重报价如下: -
sed -i $"/<!--Change here-->/ {r ${TEST_DIRECTORY}/check.html\n d}' ${TEST_DIRECTORY}/result.html"