View Single Post
Old Nov 13, 2010, 02:49 AM   #1
nick_1992
200 Posts
 
nick_1992's Avatar
 
Join Date: Jan 2006
Location: Manitoba, Canada
Posts: 471 (0.17/day)
Thanks: 73
Thanked 16 Times in 14 Posts

System Specs

Bash scripting help

So i'm trying to make a script that validates if the user input is a integer and it works but i don't know how loop the script if the input is invalid, like say they enter a "a" instead of a integer i need to be able to ask for a re-input. This is what i have so far...

#!/bin/sh
echo -n "Enter a integer: "
read x
if [ $x -eq $x 2> /dev/null ]
then
echo -e "$x is an integer"
else
echo -e "$x is not an integer"
fi
__________________
Games don't make people violent, lag does!
nick_1992 is offline  
Reply With Quote