Email if you want a copy to play with. I could use
some constructive/destructive criticism on it.
Walter
Disclaimer: My employer is not responsible for this stuff.
I have a file like that
text
+++
text
+++
text
+++
and so on.
Now I wnat to replace the first of the +++ whith the content
of another file like this:
line1
line2
line3
Result should be:
text
line1
line2
line3
text
+++
text
I tried to use sed s/"+++"/( cat file2 )/ file1 but it doesn´t work.
How can I do this on an other way ?
Best regards, Max
I also couldn't perform this with sed. Nevertheless "ed" did the job:
First assume that file2 is the file whose contents are to be inserted in file1
replacing the first line that contains +++ in the beginning of a line:
In ksh the following worked:
a one liner :
echo "/^+++/\nc\n$(<file2)\n.\nw\nq" | ed file1
or, using a here document:
ed file1 <<-EOF
/^+++/
c
$(<file2)
.
w
q
EOF
In sh the following one liner worked for me :
echo "/^+++/\nc\n`cat file2`\n.\nw\nq" | ed file1
or, using a here document :
ed file1 <<-EOF
/^+++/
c
`cat file2`
.
w
q
EOF
In csh the one liner won't work, but the here document (identical to the sh
one) works. Both of the commands that work in sh work also in ksh, but the
$(<file2) command is much more efficient than `cat file2`.
Best regards, Sharon.
In article <36C212F3...@dagobert.falkenstr.de>,
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own