zsh-users
 help / color / mirror / code / Atom feed
* test if a parameter is numeric
@ 2007-02-09 17:05 zzapper
  2007-02-10  2:29 ` Bart Schaefer
  0 siblings, 1 reply; 16+ messages in thread
From: zzapper @ 2007-02-09 17:05 UTC (permalink / raw)
  To: zsh-users

Hi embarassingly elementary but its Friday

I just want to test if a parameter is numeric

if [ "$1" -gt '0' ] && [ "$1" -lt '9' ]
then

this works but barfs (but does not exit) if $1 is non-numeric

So what's the proper way to do this pls!

hey just solved it

if [[ "$1" == [0-9] ]]

I'll post anyway just in case some poor chump googles for this one day

-- 
zzapper
http://successtheory.com/tips/ Vim, Zsh, MySQL Tips


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2007-02-20 21:36 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-09 17:05 test if a parameter is numeric zzapper
2007-02-10  2:29 ` Bart Schaefer
2007-02-10  8:35   ` Stephane Chazelas
2007-02-10 19:22     ` Bart Schaefer
2007-02-10 20:38       ` Stephane Chazelas
2007-02-10 18:13   ` Brian K. White
2007-02-10 18:31     ` Stephane Chazelas
2007-02-11  1:08     ` DervishD
     [not found]     ` <E1HG3Bl-0007Ge-DM@e4ward.com>
2007-02-20  0:14       ` Lydgate
2007-02-20  3:21         ` Andrew Ruder
     [not found]         ` <E1HJLZy-0001UA-44@b.e4ward.com>
2007-02-20  3:56           ` zsh
2007-02-20  7:02         ` Com MN PG P E B Consultant 3
2007-02-20  7:52         ` DervishD
2007-02-20 14:35           ` Frank Terbeck
2007-02-20 20:20           ` Stephane Chazelas
2007-02-20 21:35             ` Stephane Chazelas

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).