Unix Shell - Re: how to test two strings (which are numbers) for numeric

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > September 2007 > Re: how to test two strings (which are numbers) for numeric





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: how to test two strings (which are numbers) for numeric
Loki Harfagr

2007-09-27, 2:30 am

Wed, 26 Sep 2007 17:51:56 -0400, Chris F.A. Johnson did catÂ_:

> On 2007-09-26, terrence.x.13 wrote:
>
> You don't need cut or expr to do that in a POSIX shell:
>
> LINES=$(( $( wc -l < "$1" ) - 1 ))
>
>
> if [ $LINES -eq $LAST_LINE ]
> then
> echo same
> else
> echo different
> fi


Or the risky way:
# (( $LINES == $LAST_LINE )) && echo same || echo different
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com