免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1435 | 回复: 1
打印 上一主题 下一主题

[系统管理] 判断语句 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-09-19 11:27 |只看该作者 |倒序浏览
(( 0 && 1 ))
echo $? # 1 ***   为什么是 1?
# And so ...
let "num = (( 0 && 1 ))"  
echo $num # 0    为什么是0
# But ...
let "num = (( 0 && 1 ))"
echo $? # 1 ***     为什么嘛

论坛徽章:
16
CU十二周年纪念徽章
日期:2013-10-24 15:41:3415-16赛季CBA联赛之广东
日期:2015-12-23 21:21:55青铜圣斗士
日期:2015-12-05 10:35:30黄金圣斗士
日期:2015-11-26 20:42:16神斗士
日期:2015-11-19 12:47:50每日论坛发贴之星
日期:2015-11-18 06:20:00程序设计版块每日发帖之星
日期:2015-11-18 06:20:002015亚冠之城南
日期:2015-11-10 19:10:492015亚冠之萨济拖拉机
日期:2015-10-28 18:47:282015亚冠之柏太阳神
日期:2015-08-30 17:21:492015亚冠之山东鲁能
日期:2015-07-07 18:48:39摩羯座
日期:2014-08-29 23:01:42
2 [报告]
发表于 2015-09-19 19:01 |只看该作者
please man bash. then search \(\( and let:

man bash.

((expression))
              The expression is evaluated according to the rules described below under ARITHMETIC EVALUATION. If the
              value of the expression is non-zero, the return status is 0; otherwise the return status is 1
.  This is
              exactly equivalent to let "expression".

let arg [arg ...]
              Each arg is an arithmetic expression to be evaluated (see ARITHMETIC EVALUATION above).   If  the  last
              arg evaluates to 0, let returns 1; 0 is returned otherwise.

?      Expands to the exit status of the most recently executed foreground pipeline.

评分

参与人数 1信誉积分 +10 收起 理由
hjfeng1988 + 10 赞一个!

查看全部评分

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP