I've just created a bash backup script and it does work as it and I just have a question about file counting in a directory.
Below is a snippet of my code which is straightforward but I'm confused by the output. As you can see, I've set a Threshold of 7 to limit the number of backup files however when I tested the script it actually creates 8 files before it stops. This is what I can't seem to understand. If I set the threshold to 7 why is it creating 8 files and then stopping? Does it start counting from zero?
TOTALBACKUPFILES=`ls $BACKUPDIR/scripts.* | wc -l`
if [ $TOTALBACKUPFILES -le $THRESHOLD ]