您现在的位置是:网站首页> 编程资料编程资料
Shell中整数计算的几种方式_linux shell_
2023-05-26
653人已围观
简介 Shell中整数计算的几种方式_linux shell_
在Shell中可以使用下列方式来做整数的计算(+,-,*,/)
方式一:
linux:~ # A=1 linux:~ # B=2 linux:~ # C=$(($A+$B)) linux:~ # echo $C 3
方式二:
linux:~ # A=1 linux:~ # B=2 linux:~ # C=$[$A + $B] linux:~ # echo $C 3
方式三:
linux:~ # A=1 linux:~ # B=2 linux:~ # C=`expr $A + $B` linux:~ # echo $C 3
方式四:
linux:~ # A=1 linux:~ # B=2 linux:~ # let C=$A+$B linux:~ # echo $C 3
方式五:
linux:~ # A=1 linux:~ # B=2 linux:~ # C=`echo "$A+$B" | bc` linux:~ # echo $C 3
方式六:
linux:~ # A=1 linux:~ # B=2 linux:~ # awk 'BEGIN{C='"$A"'+'"$B"'; print C}' # "$A"外面再套一个单引号 3总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接
您可能感兴趣的文章:
相关内容
- Shell中统计字符串中单词的个数的几种方法_linux shell_
- Shell中去除字符串前后空格的方法_linux shell_
- shell中使用expect命令进行远程执行命令脚本_linux shell_
- shell命令实现当前目录下多个文件合并为一个文件的方法_linux shell_
- Linux shell命令统计某列去重后的值_linux shell_
- Linux shell脚本的建立与执行_linux shell_
- Linux shell数组与关联数组的用法实例_linux shell_
- 浅谈shell脚本中的控制流结构_linux shell_
- shell查找某字符串在某文件中出现行数的方法_linux shell_
- Linux Shell 生成随机数和随机字符串的方法示例_linux shell_
