My sed-foo is weak. How do I replace text with input from stdin?

Essentially I want:

echo "foo" | sed 's/to_be_replaced/$from_stdin/' template.txt


I got it sorted.
I just split it into two parts:

FOO=$(echo "foo")
sed -e "/to_be_replaced/${FOO}/" template.txt > output.txt

· · Web · 0 · 0 · 1
Sign in to participate in the conversation

A instance dedicated - but not limited - to people with an interest in the GNU+Linux ecosystem and/or general tech. Sysadmins to enthusiasts, creators to movielovers - Welcome!