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
原文地址:https://www.cnblogs.com/faberbeta/p/12867412.html