Trying to make script to insert file into tmp.txt
Posted: Tue 02 Oct 2012, 03:34
G'day,
After trawling through the Internet I've come to a standstill with the following script. And I'm not a scripting guru....
I want to insert the file exit1.tx into the middle of tmp.txt.
I know that the expressions for lines and middle work however it doesn't want to play ball with sed. If I substitute ${middle} with a number then the sed expression works
exit1.txt has this:
so it's chock full of characters which interfere with sed's syntax.
The answer is probably simple but so am I...
Cheers
Martin
After trawling through the Internet I've come to a standstill with the following script. And I'm not a scripting guru....
I want to insert the file exit1.tx into the middle of tmp.txt.
Code: Select all
#!/bin/sh
file=tmp.txt
lines=`wc -l $file |awk '{print $1}'`
middle=`expr $lines / 2`
sed -i '${middle}r exit1.txt' tmp.txt
exit1.txt has this:
Code: Select all
<icon x="704" y="704" label="Exit User Desktop">/usr/share/Audio-lauchers/desktop/User/exit</icon>
The answer is probably simple but so am I...
Cheers
Martin