Re: How to determine integer?
2010-03-13, Decare skribis:
Is there any to determine whether a string
is a integer or not? For example,
read s
if [ ... ]; then
do something
else
do another
fi
I came across this kind of hack:
is_int() {
printf "%d" $1 > /dev/null 2>&1
return $?
}
read s
if is_int "$s"; then
echo "$s is an integer."
else
echo "$s is not an integer."
fi
--
kasmra
:wq
.
Relevant Pages
- Re: set user=%username%
... Your most recent feedback confirms that Windows is ... Type this: echo %MyName% ... > usertest=This is a long string. ... (microsoft.public.windows.server.general) - Re: its not the school home work
... I've learned a bit about strong quotes and think I realized when to ... the shell (such as in the $var, but also for the spaces (that ... echo "foo bar" ... you may say that $string does not appear in /list/ context so ... (comp.unix.shell) - Re: TRUE and FALSE are treated differently
... No -- you can't echo a boolean in PHP. ... If you look up the manual on type casting, you'll find that FALSE is cast ... to an empty string, and TRUE is cast to a non-empty string. ... (comp.lang.php) - Re: TRUE and FALSE are treated differently
... No -- you can't echo a boolean in PHP. ... the boolean is implicitly cast to a string. ... If you look up the manual on type casting, you'll find that FALSE is cast to an empty string, and TRUE is cast to a non-empty string. ... (comp.lang.php) - Re: WEB SITE PROJECT DEPLOYMENT ~ Help please??
... ECHO When/If prompted with the question: ... The files are all now sitting on my Server, and when I load my web site, ... An error has occurred while establishing a connection to the server. ... The connection string specifies a local Sql Server Express instance using ... (microsoft.public.dotnet.framework.aspnet) |
|