Helo.
If I've understood you, this would fit your needs:
Code:
#!/bin/bash
# Initial value used to compare.
val=0
echo "initial val=$val"
echo "-----------"
# For each file whose name starts with "DFC" and is under files/ folder do
for f in $(ls -1 files/DFC*); do
echo "File: $f"
# get the number from the filename
num=$(echo $(basename $f) | cut -d. -f1|cut -c4-)
echo "num: $num"
# Compare it to val value
if [ $num -gt $val ]; then
# It's greater, so update val value and delete file.
val=$num
rm $f
echo "${f} deleted."
fi
echo "val=$val"
echo "--"
done
echo "-----------"
echo "###########"
echo "-----------"
echo "val=$val"