user11305715
user11305715

Reputation: 1

How to use sed with here-document?

I am trying to use a here-document with sed with a script.. but I get an weird error.

sed: can't read Some random text.: No such file or directory

FILE=c:/output.file

read -r -d '' VAR <<"EOF"
Some random text.
EOF

./sed -f - "$VAR" > "$FILE" << SED_SCRIPT
s|text|word|g
s|Some|Lots of|g
SED_SCRIPT

Upvotes: 0

Views: 604

Answers (1)

rghome
rghome

Reputation: 8819

You don't use a here document for the sed expression, you just use a parameter in quotes. You normally use the here document for the input.

    sed -e 's/text/word/g
s/Some/Lots of|g' <<EOF
Some random text.
EOF

Upvotes: 1

Related Questions