On Thu, 2009-03-12 at 15:56 +0000, Roy Marples wrote:
> > one thing I didnt find yet in any docu: how can I catch if a string is
> > entered instead of a number with read?
> 
> if ! printf "%d" $n >/dev/null 2>&1; then
>     echo "You didn't enter a number"
>     exit 1
> fi

Alternatively:

        case $n in
            *[^0-9]*) echo "You didn't enter a number"; exit 1 ;;
        esac

(checks to see if any non-numeric character exists in $n).

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to