Greetings all.
I have come across a problem that I am struggling to solve (correctly).
I am looking to write a script that does the following.
1. I have a file that contains the follwing.
file1
#REPLACE_1
some written text...
#REPLACE_2
some more text
2. I then have 2 file that contain lines that should replace the tags.
File REPLACE_1 contains
LINE1
LINE2
File REPLACE_2 contans
LINE3
LINE4
My problem is that I cannot get the whitespaces/newlines to be included in the merged file. Any ideas would be most appreciated as it is starting to drive me round the bend!!
So to sum up the resulting file should look like this:
RESULTS FILE
LINE1
LINE2
some written text...
LINE3
LINE4
some more text
I thank you all in advance.
Si
Forgot to say. That at present there are never any whitespaces/newlines. So the followng code I wrote work fine for what I need.
Go easy on it as I am no expert. Current solution is:
grep -i ^#REPLACE_ $file > ./tmpreplace
while read replace
do
awk ' BEGIN { RS="" }
FILENAME==ARGV[1] { r=$0; s=FILENAME }
FILENAME==ARGV[2] { sub(s,r) ; print }
' $replace $file > $tfile
file=$tfile
cnt=$cnt+1
tfile="TMP"$cnt
done < ./tmpreplace