I have two different files:
/home/user1/ /home/user2/bin /home/user1/a/b/c
I want to replace the
<TEXT1> of File2 with the contents of File1 using
sed. I tried this command, but not getting proper output:
cat File2|sed "s/<TEXT1>/$(cat File1|sed 's/\//\\\//g'|sed 's/$/\\n/g'|tr -d "\n")/g"
You can use other tools also to solve this problem.
sedimplementation are you using. You code works for me with GNU
/home/user1/ n/home/user2/bin n/home/user1/a/b/cn <TEXT2>. Not getting new lines.
patchtools allow to replace some lines in a file by other lines quite easily.
$()in a sed script makes my eyes bleed. Never use external data in places where some characters are interpreted with special meaning.