[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: how to check given value in a shell variable is number orstring



Surprisingly, there seems to be no direct way to check.
But one can use something like

if [ -z "`echo $VARIABLE | tr -d "[:digit:]"`" ]

Regards,
Bharavi

> -----Original Message-----
> From: rpm-list-admin@redhat.com [mailto:rpm-list-admin@redhat.com]On
> Behalf Of jsmurthy
> Sent: Monday, June 23, 2003 8:47 AM
> To: rpm-list@redhat.com
> Subject: RE: how to check given value in a shell variable is number
> orstring
> 
> 
> 
> 
>  sorry sv, before posting itself i tried man test, but could 
> not figure it
> from  out.. there in the man list
>   all commands are for checking file status........
> 
> regards
>  j.s.murthy
> 
> 
> 
> 
> -----Original Message-----
> From: rpm-list-admin@redhat.com [mailto:rpm-list-admin@redhat.com]On
> Behalf Of seth vidal
> Sent: Wednesday, June 25, 2003 10:42 AM
> To: rpm-list@redhat.com
> Subject: Re: how to check given value in a shell variable is number
> orstring
> 
> 
> On Sun, 2003-06-22 at 22:59, jsmurthy wrote:
> >
> >
> >   can any one tell how to check whethter stored value in a 
> shell variable
> is
> > number or string.
> >
> >
> >  for example : to check emptynull string we use if [ -z 
> variable ] .......
> >
> read:
>  man test
> 
> it explains all the nice test operations
> 
> -sv
> 
> 
> 
> 
> 
> _______________________________________________
> Rpm-list mailing list
> Rpm-list@redhat.com
> https://www.redhat.com/mailman/listinfo/rpm-list
> 
> 
> _______________________________________________
> Rpm-list mailing list
> Rpm-list@redhat.com
> https://www.redhat.com/mailman/listinfo/rpm-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []