[NTLUG:Discuss] basic Bash question

George Lass George.Lass at osc.com
Tue Aug 3 11:41:50 CDT 2004


You can always check $? directly after
the test, and if it is "2" then test
returned an error.  Just keep in mind that
the act of looking at $? will change it,
so you only get 1 chance to see if it is "2"
George

fredjame wrote:
> 
> Lance Simmons wrote:
> 
> >I need to test whether a string is an integer.
> >
> >I'm tailing a logfile and extracting a string.  99 times out of 100 the
> >string is an integer, but sometimes, because of the program that creates
> >the logfile, it's not an integer.
> >
> >Is there a simple way in a bash script to test whether a string is an
> >integer?
> >
> I'm thinking pipe the string trough awk or grep, but there may be an
> easier way.
>



More information about the Discuss mailing list