Supondo que você tenha todos os arquivos a serem validados desde o início.
#!/bin/bash
seqno=1
for i; do
if tail -1 $i | grep -q $(printf "%016d\$" $seqno); then
echo " valid: $i"
seqno=$((seqno+1))
else
echo "invalid: $i"
fi
done
Entrada:
$ grep . EFEGECC*
EFEGECC_20150101.txt:9999 TR SAP _AP Distribution 0000000000000001
EFEGECC_20150102.txt:9999 TR SAP _AP Distribution 0000000000000002
EFEGECC_20150103.txt:9999 TR SAP _AP Distribution 0000000000000002
EFEGECC_20150104.txt:9999 TR SAP _AP Distribution 0000000000000009
EFEGECC_20150105.txt:9999 TR SAP _AP Distribution 0000000000000003
Saída:
$ ./script.sh EFEGECC*
valid: EFEGECC_20150101.txt
valid: EFEGECC_20150102.txt
invalid: EFEGECC_20150103.txt
invalid: EFEGECC_20150104.txt
valid: EFEGECC_20150105.txt