shell 浮点数和整数比较大小
我们知道在shell里面用> 或者gt lt都只是可以比较整数
在shell里面可以用bc命令和 awk命令比较两个浮点数或者浮点数和整数
例如
#!/bin/bash a=7.2 b=8 if [ `echo "$a < $b"|bc` -eq 1 ] ; then echo "$a < $b " else echo "$a > $b " fi
bc Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty‘. 7.2>8 0 7.2<8 1
相关推荐
风雨断肠人 2020-10-13
Cwiky 2020-07-18
Greatemperor 2020-07-04
RuoShangM 2020-06-28
paopao00 2020-06-08
长安长夜Saint 2020-06-07
flyingssky 2020-06-04
fanhuasijin 2020-05-30
breakpoints 2020-05-19
cyydjt 2020-05-18
eroshn 2020-05-06
qingsongzdq 2020-04-26
ericasadun 2020-04-26
lynjay 2020-04-26
choupiaoyi 2020-04-26
jyj00 2020-04-20
choupiaoyi 2020-04-18
qingsongzdq 2020-04-18
kuoying 2020-04-10