let 命令

博客介绍了let命令取代并扩展了expr命令的整数算数符号。它支持5种基础运算符,还有自变运算符和幂次运算符,在变量计算中无需加特殊符号表示变量,且对空格要求严格。

let命令取代并扩展了expr命令的整数算数符号。

let除了支持5中基础的运算符。

还支持+=,-=,*=,、-,%= 自变运算符。

以及**幂次运算符。

在变量计算中不需要加上$来表示变量。

[centos@s201 ~]$ let a=1+2
[centos@s201 ~]$ echo $a
3
[centos@s201 ~]$ let b=3-2
[centos@s201 ~]$ echo $B

[centos@s201 ~]$ echo $b
1

[centos@s201 ~]$ let c=8/6
[centos@s201 ~]$ echo $c
1

[centos@s201 ~]$ let c=8%6
[centos@s201 ~]$ echo $c
2

 

自加操作:let no++
自减操作:let no--
简写形式 let no+=10,let no-=20,分别等同于 let no=no+10,let no=no-20

 

 

对空格比较严格

[centos@s201 ~]$ let c= 8/6
-bash: let: c=: syntax error: operand expected (error token is "=")
[centos@s201 ~]$ let c = 8/6
-bash: let: =: syntax error: operand expected (error token is "=")

 

转载于:https://www.cnblogs.com/wqbin/p/10885671.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值