Re: BASH script arguments

From: Grant Edwards (grante_at_visi.com)
Date: 10/02/04


Date: 02 Oct 2004 00:58:14 GMT

On 2004-10-01, Dale Bourne <dbourne@chartertn.net> wrote:

> I'm new to scripting. I've learned quite a bit following the
> newsgroups, and online tutorials. Still have a long way to go.
>
> How can I determine if a commandline argument is an integer?

if expr "$1" : '[0-9][0-9]*$' >/dev/null; then
  echo "integer"
fi

-- 
Grant Edwards                   grante             Yow!  Mr and Mrs PED, can I
                                  at               borrow 26.7% of the RAYON
                               visi.com            TEXTILE production of the
                                                   INDONESIAN archipelago?


Relevant Pages

  • Re: BASH script arguments
    ... On 2004-10-01, Dale Bourne wrote: ... > I'm new to scripting. ... I've learned quite a bit following the newsgroups, ... > and online tutorials. ...
    (comp.os.linux.misc)
  • Re: BASH script arguments
    ... Dale Bourne wrote: ... > I'm new to scripting. ... I've learned quite a bit following the newsgroups, ... > and online tutorials. ...
    (comp.os.linux.misc)
  • Re: BASH script arguments
    ... Dale Bourne wrote: ... I've learned quite a bit following the newsgroups, ... > and online tutorials. ... The arg could also be an integer expression such as "1+1" ...
    (comp.os.linux.misc)
  • BASH script arguments
    ... I'm new to scripting. ... I've learned quite a bit following the newsgroups, ... and online tutorials. ... How can I determine if a commandline argument is an integer? ...
    (comp.os.linux.misc)