[H-GEN] Shell script problem.

A Bruce In The Land Of The Bruces brucec at humbug.org.au
Thu Jun 4 21:30:12 EDT 1998


On Fri, 5 Jun 1998, Andrae Muys wrote:

> 14 3.63234e+07
> 28 3.54324e+07
> 
> Now short of writing a C program to do the final step, can anyone help?

what, sort -nk 2  ?   That provides the easy answer based on the example
data, but not if different exponentials are involved.  Hmmm, perhaps:

lowestexp="`cat $input | sort -nt '+' -k 2 | head -n 1 | cut -d '+' -f 2`"
lowest="`cat $input | sort -nk 2 | grep $lowestexp | head -n 1`"

might work.  Still involves too many passes through the possibly large
input file - better off writing a short C to do it if the files are large.

--==--
Bruce.

numeric sort based on field #2, assuming fields are whitespace seperated.




----------------------- HUMBUG General List --------------------------------
echo "unsubscribe general" | mail majordomo at humbug.org.au # To Unsubscribe



More information about the General mailing list