#!/bin/sh
if test $1 = '-h'
then
echo "***************************"
echo "*** Add 'FILE1' inside  ***"
echo "*** 'FILE2' at line 'N' ***"
echo "***************************"
echo "add_file-at.bash 'FILE2' 'N' 'FILE1'"
else
foresthome=`(pwd)`
foresthome=${foresthome}/..
num_lines=`(wc -l $1 | awk '{print $1}')`
iline=1
while test $iline -le ${num_lines}
do
awk -f ${foresthome}/AWK/line.awk row=$iline $1 > line.inf
if test $iline -ne $2
then
if test $iline -eq 1
then
cat line.inf > $1.bkp
else
cat line.inf >> $1.bkp
fi
else
if test $iline -eq 1
then
cat $3 > $1.bkp
else
cat $3 >> $1.bkp
fi
cat line.inf >> $1.bkp
fi
iline=`(expr ${iline} + 1)`
done
mv $1.bkp $1
rm line.inf
fi
