linux let命令,Linux 下(())、let 、expr 、bc、typeset命令 | Byrd's Weblog

[root@LAMP ~]# ((a=1+2**3-4%3))

[root@LAMP ~]# echo $a

8

[root@LAMP ~]# b=$((1+2**3-4%3))

[root@LAMP ~]# echo $b

8

[root@LAMP ~]# echo $((a+=1))

9

[root@LAMP ~]# echo $((a*=2))

18

[root@LAMP ~]# echo $a

18

[root@LAMP ~]# echo $((a%=2))

0

[root@LAMP ~]# echo $((a+=8))

8

[root@LAMP ~]# echo $((a/=2))

4

[root@LAMP ~]# echo $((a++))

4

[root@LAMP ~]# echo $a

5

[root@LAMP ~]# echo $((a++))

5

[root@LAMP ~]# echo $a

6

[root@LAMP ~]# echo $((a--))

6

[root@LAMP ~]# echo $a

5

[root@LAMP ~]# echo $((++a))

6

[root@LAMP ~]# echo $a

6

[root@LAMP ~]# echo $((--a))

5

[root@LAMP ~]# echo $a

5

[root@LAMP ~]# echo $((3>1))

1

[root@LAMP ~]# echo $((3<1))

0

[root@LAMP script]# i=2

[root@LAMP script]# let i=i*3

[root@LAMP script]# echo $i

6

[root@LAMP script]# expr length "byrd"

4

[root@LAMP script]# expr substr "byrd" 2 2

yr

[root@LAMP test]# seq -s " " 100

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

[root@LAMP test]# echo ${#chars}

291

[root@LAMP test]# echo $(expr length "$chars")

291

[root@LAMP test]# expr length "$chars"

291

[root@LAMP test]# echo {chars}|wc -L

291

[root@LAMP test]# time for i in $(seq 50000);do count=`echo ${#chars}`;done;

real 0m22.605s

user 0m1.416s

sys 0m5.814s

[root@LAMP test]# time for i in $(seq 50000);do count=`echo {chars}|wc -m`;done;

real 1m25.007s

user 0m2.362s

sys 0m8.060s

[root@LAMP test]# time for i in $(seq 50000);do count=`expr length "{chars}"`;done;

real 0m46.205s

user 0m2.646s

sys 0m10.198s

[root@LAMP test]# time for i in $(seq 50000);do count=`echo expr length "{chars}"`;done;

real 0m25.122s

user 0m1.794s

sys 0m6.744s

[root@LAMP test]# time for i in $(seq 50000);do count=`expr length "{chars}"`;done;

real 0m46.836s

user 0m3.100s

sys 0m10.740s

[root@LAMP test]# time for i in $(seq 50000);do count=`echo {chars}|wc -L`;done;

real 1m31.203s

user 0m3.148s

sys 0m12.504s

[root@LAMP test]# echo "obase=2;205"|bc

11001101

[root@LAMP test]# echo "obase=8;205"|bc

315

[root@LAMP test]# echo "obase=10;205"|bc

205

[root@LAMP test]# echo "obase=16;205"|bc

CD

[root@LAMP test]# seq -s "+" 100

1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69+70+71+72+73+74+75+76+77+78+79+80+81+82+83+84+85+86+87+88+89+90+91+92+93+94+95+96+97+98+99+100

[root@LAMP test]# seq -s "+" 100|bc

5050

[root@LAMP test]# echo {1..100}

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

[root@LAMP test]# echo {1..100}|tr " " "+"

1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+21+22+23+24+25+26+27+28+29+30+31+32+33+34+35+36+37+38+39+40+41+42+43+44+45+46+47+48+49+50+51+52+53+54+55+56+57+58+59+60+61+62+63+64+65+66+67+68+69+70+71+72+73+74+75+76+77+78+79+80+81+82+83+84+85+86+87+88+89+90+91+92+93+94+95+96+97+98+99+100

[root@LAMP test]# echo {1..100}|tr " " "+"|bc

5050

[root@LAMP test]# typeset -i A=1 B=3

[root@LAMP test]# A=A+B

[root@LAMP test]# echo $A

4

[root@LAMP test]# echo $[2+3]

5

[root@LAMP test]# echo $[ 2 + 3 ]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值