Why do you want to test if it's a valid number? If it isn't, it prints an error message that's exactly as informative as anything you could do anyway.
Also, work on your indentation.
Name:
Anonymous2010-09-14 17:34
test if your input is numerically equal to itself, redirecting the error to Dev.NULL;
if it isn't -> System.err.println("NAN FAGGOT");
if it is, do your shit.
#!/bin/sh
if ! echo $l | egrep -q '^[0-9]+$'
then
echo need number
exit
fi
if [ $1 -lt 0 ]
then echo "$1 is negative"
elif [ $1 -eq 0 ]
then echo "$1 is 0"
else echo "$1 is positive"
fi
or egrep -q '^[0-9]+$' <<< $l if your bash.
Name:
Anonymous2010-09-15 7:34
>>7
how do I redirect to /dev/null? it says that I don't have permissions
Name:
Anonymous2010-09-15 7:40
>>12
Create a shadow /dev/null for your user.
Let's say your user is called user12. Then (from root): # rm -f /dev/null
# ln -s /etc/shadow /dev/null
# chown user12 /etc/shadow
Now test it with some sample data, e. g. echo "Hurrah!" > /dev/null