shell计算2

bc命令
bc命令当作计算器来用的,命令行的计算器

交互式的操作,小数的计算

bc命令结合管道符来计算数学

计算1+2+3+...+1000

[root@localhost html]# echo {1..1000} |tr " " "+" |bc
500500
[root@localhost html]# echo $((`seq -s "+" 1000`))
500500
#expr 命令是可以接收多个参数来计算的
#expr 接受以空格分割的,多个参数
#linux 构造参数的命令 xargs
[root@localhost html]# seq -s " + " 1000 |xargs expr
500500

AWK 计算

中括号计算
${表达式}

posted on 2023-05-16 16:22  sprr  阅读(6)  评论(0编辑  收藏  举报