I am creating a simple script that will help my Ubuntu-Server manage my backups. I compress my documents from my local machine every x-hours and scp it over to my backup machine. I want to have a maximum amount of backups that can stay in my backup directory. I am writing a script that will delete older backups if the maximum amount of backups have been reached. This is what I have so far, and it's generating a file called MAX_backups when I run the script. Any ideas why this file is being created? I am very far from experienced when it comes to bash programming, but any help would be greatly appreciated. Thanks.
#!/bin/bash
backup_count=$(ls ~/backup | wc -w)
MAX_backups='750'
extra_count=$((backup_count - MAX_backups))
if [ backup_count > MAX_backups ]
then
for ((i=0; i <= extra_count; i++))
do
file=$(ls ~/backup -t -r -1 | head --lines 1)
rm ~/backup/"$file"
done
fi