bc 命令
bc 命令计算
[root@localhost ~]# bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
3+6
9
9-7
2
9*3
27
9/2
4
9%2
1
9.9%3
.9bc 命令结合管道符计算
计算1-100的总和
方案1:使用echo打印出1-100,tr将空格替换为+,然后交给bc
方案2:使用seq生成数字,然后交给bc
方案3:使用seq生成数字,然后用(())
方案4:使用seq生成数字,然后传参给expr
Last updated