珠一
caojiangfeng
热爱开源,热爱linux
全部博文(213)
hadoop(3)
perl脚本(4)
jvm调优工具(1)
网络编程(1)
用法与技术(10)
程序(12)
日志相关(1)
sed和awk(9)
循环(1)
有用的shell网址(0)
驱动开发(4)
我的shell脚本(9)
shell(12)
应用配置(11)
模块编程(10)
Kernel(8)
条件语句(2)
其他(6)
命令学习(20)
信号及其信号处理(3)
进程(7)
文件系统(1)
系统配置(12)
2018年(4)
2017年(1)
2015年(1)
2014年(5)
2013年(2)
2012年(2)
2011年(21)
2010年(82)
2009年(72)
2008年(23)
RHCE520
FIGHTERB
simiaoxi
lyanxha
huxuelin
liurhyme
wangxinm
bluesea6
联众集群
wb123456
ui56
uccom1
dahaosha
gu111356
cynthia
w3964549
a5940176
fah9394
分类: LINUX
2010-09-09 16:50:54
#!/bin/bash # Script:cmp_decemial.sh # Author:CaoJiangfeng # Date:09/09/2010 # Purpose: This script is used to cmp two decemial number's bigness # # The numbers which are going to be comapred a=$1 b=$2 #Obtain the number of decimal places after the decimal point c=`echo "$a"|awk 'BEGIN{FS="."} {print length($2)}'` d=`echo "$b"|awk 'BEGIN{FS="."} {print length($2)}'` #Obtain the maximum number of decimal places after the decimal point if [ $c -ge $d ]; then tmp=$c else tmp=$d fi #Multiple variable expansion temp=1 for ((i = 0; i < $tmp;i ++)); do temp=${temp}0 done #After the expansion multiple of the value of temp a1=`echo "$a*$temp" |bc` b1=`echo "$b*$temp" |bc` #Get integer part c=`echo "$a1"|awk 'BEGIN{FS="."} {print $1}'` d=`echo "$b1"|awk 'BEGIN{FS="."} {print $1}'` #Compare the size of two numbers if [ $c -gt $d ]; then echo "$a > $b" elif [ $c -eq $d ]; then echo "$a = $b" else echo "$a < $b" fi
# Script:cmp_decemial.sh # Author:CaoJiangfeng # Date:09/09/2010 # Purpose: This script is used to cmp two decemial number's bigness # # The numbers which are going to be comapred a=$1 b=$2 #Obtain the number of decimal places after the decimal point c=`echo "$a"|awk 'BEGIN{FS="."} {print length($2)}'` d=`echo "$b"|awk 'BEGIN{FS="."} {print length($2)}'` #Obtain the maximum number of decimal places after the decimal point if [ $c -ge $d ]; then tmp=$c else tmp=$d fi #Multiple variable expansion temp=1 for ((i = 0; i < $tmp;i ++)); do temp=${temp}0 done #After the expansion multiple of the value of temp a1=`echo "$a*$temp" |bc` b1=`echo "$b*$temp" |bc` #Get integer part c=`echo "$a1"|awk 'BEGIN{FS="."} {print $1}'` d=`echo "$b1"|awk 'BEGIN{FS="."} {print $1}'` #Compare the size of two numbers if [ $c -gt $d ]; then echo "$a > $b" elif [ $c -eq $d ]; then echo "$a = $b" else echo "$a < $b" fi
上一篇:shell脚本实现自动创建C语言文件
下一篇:Linux Shell for循环写法总结
登录 注册