On 11/7/05, Nestor <[EMAIL PROTECTED]> wrote:
> People,
>
> I am running a script and I am trying to compare 2 values.
>
> The input file looks like
> 111-11-1111| 24000.00
> 222-22-2222| 32560.15
> 333-33-3333| 45678.90
>
> The script loks like this
> ----------------------------------------------------
> TMP_FILE = "myfoo"
> IFS = '|'
>
> cat $TMP_FILE | while read SSN AMT; do {
> if [ $AMT -gt $limit ] ; then
> echo $AMT $SSN
> fi
> } done
> ---------------------------------------------------
> The warning is:
> + read SSN AMT
> + '[' 14402.40 -gt 90000.00 ']'
> nestor2.sh: line 50: [: 14402.40: integer expression expected
>
> How do you compare 2 float in shell script preferrable in cshell?
>
You don't. You use some other scripting language that knows what floats are.
Also, if you want your program to produce output from the sample data
set, you choose the boundary value so that some data is above and some
below. Example:
[EMAIL PROTECTED] nestor]$ cat data
111-11-1111| 24000.00
222-22-2222| 32560.15
333-33-3333| 45678.90
[EMAIL PROTECTED] nestor]$ cat script
#!/bin/awk -f
BEGIN{ FS="|"; limit=30000 }
{
if ($2 > l) { print $2, $1 }
}
[EMAIL PROTECTED] nestor]$ ./script data
32560.15 222-22-2222
45678.90 333-33-3333
carl
--
carl lowenstein marine physical lab u.c. san diego
[EMAIL PROTECTED]
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list