If the requirement is that only digits may occur, you can test for the negation of a string of 1 or more digits instead:
if ! [[ $lastseen =~ ^[0-9]+$ ]]; then
echo "Serial Number is invalid: it does not consist entirely of digits"
exit 3
fi
With regular patterns you could use:
case $lastseen in
(*[!0-9]*|"")
echo "Serial Number Invalid: it does not consist entirely of digits"
exit 3
;;
esac
---
You can use one condition like so:
if [[ -z $lastseen || $lastseen == *[_a-zA-Z]* ]]; then
---
To use regexes you need to leave them unquoted. But even without the quotes, this would seem to do the opposite of what is required. The left condition tests whether a string consists exclusively of alpha characters (letters) or is empty, whereas the requirement is that no non-digits may occur.
This is the only reply, in the few that have been posted, that is fully POSIX compliant and will work in 'sh' and 'dash' too, thus making it basically portable...