Insert content of file after first pattern match u

2019-09-02 07:16发布

I need to find first occurrence of "all.css" and insert content of my file below this occurrence. Code that I use in my bash-script:

FILE="$OLD_WEB_SOURCES/logon.html"
BLA="$DIR/first_insert_android" 
sed '/all.css/ r $BLA' "$FILE" > TMP1
mv TMP1 "$FILE"

But this code doesnt work for me. BTW echo of variables FILE and BLA shows correct path. Can someone explain what I'm doing wrong?

标签: bash shell sed
1条回答
男人必须洒脱
2楼-- · 2019-09-02 08:11

You need to use double quotes( " ) to access the shell variable( $BLA ) in sed. Try this,

sed "/all.css/ r $BLA" "$FILE" > TMP1
查看更多
登录 后发表回答