My apologies for the pun ...
Here's a code fragment that may help:
Code:
# define source file
OLD=<source file>
# define insert file
TXT=<insert file>
# define result file
NEW=<result file>
# set insert point
N=<insert point>
# calculate file length
L=`wc -l $OLD | awk '{print $1}'`
# calculate remaining file length
(( M = $L - $N + 1))
# assemble the new file
head -$N $OLD > $NEW
cat $TXT >> $NEW
tail -$M $OLD >> $NEW
There are other ways to get/define the inserted text, amongst them:
- "here" doc embedded in the script
- reading the text from the command line
- reading a file name from the command line