Mombu the GNU Linux Forum sponsored links

Go Back   Mombu the GNU Linux Forum > GNU_Linux > compare non-integer vaiables in bash/gawk?
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 26th February 20:43
maggie
External User
 
Posts: 1
Default compare non-integer vaiables in bash/gawk?



Hi there,

I want to compare the output of two variables from two gawk command,
for example, v1=1221.73, v2=1441.33. I want to write a script or
anything that's conveient to do to compare these two variables and tell
which is bigger. I found that bash can only handle integers/characters.


My knowledge of script programming is quite limited. Could anyone give
me a little bit idea of what to do?

Thanks,
Maggie
  Reply With Quote


  sponsored links


2 26th February 20:43
maggie
External User
 
Posts: 1
Default compare non-integer vaiables in bash/gawk?



Sorry, but I solved this problem short after I posted this message.
Please ignore it.

Thanks,
Maggie
  Reply With Quote


  sponsored links


3 26th February 20:43
mark atherton
External User
 
Posts: 1
Default compare non-integer vaiables in bash/gawk?


Try this:

[mark@hotspur ~]$ echo '3.14159 2.71828 - p' | dc
..42331
[mark@hotspur ~]$ echo '2.71828 3.14159 - p' | dc
-.42331

dc is a RPN command line calculator, and is in the bc rpm. You can grep
the output for '-' and use the result of grep.

Mark Atherton
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666