Results 1 to 4 of 4
Hello! I am new to bash programming, and I have messed around with integers and matrices, but I am curious if doubles can be used. lets say I have a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.

 03242014 #1
 Join Date
 Mar 2014
 Posts
 1
Bash(awk)  comparing decimal values from file
14.23 15.10 10.90
Now I want to find the smallest DECIMAL value of these and print it out. So 15.10 would be the printout. Can I write a bash script for this? I would like to use awk because I feel it is the easiest.
 03242014 #2
 Join Date
 Nov 2012
 Posts
 224
hi,
what if an equality happens ?
e.g. :Code:25.35 12.10 65.10 34.24
 03242014 #3
How about this:
Code:$ cat deccomp echo 14.23 15.10 10.90  awk ' function trunc(x) { return x  int(x) } { if (NF > 0) { smallest = $1 for (i = 2; i<=NF; i++) { curr = trunc($i) if (trunc(smallest) > curr) smallest = $i } print smallest } }' $ sh deccomp 15.10 $
 03242014 #4