求和
[root@localhost linux]# cat num.txt
1
2
3
4
5
6
7
8
9
10
[root@localhost linux]# cat num.txt |tr "\n" "+"
1+2+3+4+5+6+7+8+9+10+
[root@localhost linux]# cat num.txt |tr "\n" "+"|sed 's@+$@\n@'|bc
55
求和
[root@localhost linux]# cat num.txt
1
2
3
4
5
6
7
8
9
10
[root@localhost linux]# cat num.txt |tr "\n" "+"
1+2+3+4+5+6+7+8+9+10+
[root@localhost linux]# cat num.txt |tr "\n" "+"|sed 's@+$@\n@'|bc
55
转载于:https://my.oschina.net/2726276586/blog/1491673