祁连踏雪 阳关揽月 扬鞭踏马胭脂山 踩沙逐浪黑河岸 分享 http://blog.sciencenet.cn/u/shenxzh

博文

Convert the string to number and compare

已有 2513 次阅读 2012-2-1 15:19 |个人分类:Shell scripts|系统分类:科研笔记| class, Number, default, compare

Use bc
$ echo
"0.8 > 0.7" | bc
1
$ echo
"0.8 < 0.7" | bc
0
$ echo
".08 > 0.7" | bc
0

use awk

x="0.80"
y
="0.70"
result
=$(awk -vx=$x -vy=$y 'BEGIN{ print x>=y?1:0}')
if [ "$result" -eq 1 ];then
    echo
"x more than y"
fi



https://blog.sciencenet.cn/blog-381041-533341.html

上一篇:check the existance of a directory in a bash shell
下一篇:关爱孩子 关爱你们的未来!
收藏 IP: 202.100.91.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-13 06:31

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部