[NTLUG:Discuss] basic Bash question

brad angelcyk bradangelcyk at yahoo.com
Tue Aug 3 10:34:23 CDT 2004


Could you just use test?

$ test 1 -gt 0
$ test a -gt 0
bash: test: a: integer expression expected


--- fredjame <fredjame at fredjame.cnc.net> 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.
> 
> -- 
> ...we are fellow passengers...
> 
> 
> _______________________________________________
> https://ntlug.org/mailman/listinfo/discuss
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Discuss mailing list