Need borne shell to delete all but last two backups
I wrote this shell scrip whose intent is to delete all but the last two files that match a particular pattern. I am attempting to set the variable $backupcnt to the number of files that match the pattern in line 4.
The script fails on line 4 with: "line 4: backupcnt: command not found" and on the while loop test: " line 6: [: -ge: unary operator expected"
set -v -x
backupcnt = $(ls -t -1 | grep $1_`hostname` | wc -l)