user1248568
user1248568

Reputation: 621

Insert content of file after first pattern match using sed

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?

Upvotes: 0

Views: 1398

Answers (1)

sat
sat

Reputation: 14949

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

sed "/all.css/ r $BLA" "$FILE" > TMP1

Upvotes: 2

Related Questions