Ok, this is what I've tried so far, and it seems to work
Code:
if [ -z $1 ]; then
echo "Needs directory as argument."
exit 1
elif [ -d "$1" ]; then
dirname="$1"
fi
cd $1
list="$(ls ARCH*.test)"
echo $list
for i in $list
do
sed -i '$a\
QUAL 6 STATUS TEST\
ARCHIVE 12\
partial k-effective\
retrieve from ./REF_INTS/nnn_testy.REFINT\
begin\
INTER x 12\
compare k-effective\
begin\
\
QUAL 3 STATUS REFERENCE\
ARCHIVE x\
partial k-effective\
store as ./REF_INTS/nnn_testy.REFINT\
begin' $i
done
for i in $list
do
sed -i s/nnn/"$1"/ $i
done
2 more things..........
(a) I now need to strip out part of the filename,a numeric character after the word "test" in the filename, and sub that for y in text to append
(b) I need to spool through the input file, before appending to it, and find the last occurrence of a word from a look up list. When that occurs, I need to strip out the last numerical character from that line, and again sub for x in text to append. Can I use awk for that?
I guess I need to do these three amendments to the text to append before doing the appending..............