Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | Email

26.6. Numeric

26.6.1. 数值运算

echo $((3+5))
expr 6 + 3
awk 'BEGIN{a=(3+2)*2;print a}'
		

26.6.2. seq - print a sequence of numbers

[neo@test ~]$ seq 10
1
2
3
4
5
6
7
8
9
10
[neo@test ~]$ seq 5 10
5
6
7
8
9
10

		

等差列, 步长设置

$ seq 1 1 10
1
2
3
4
5
6
7
8
9
10

$ seq 1 2 10
1
3
5
7
9

# seq 0 2 10
0
2
4
6
8
10
		

分隔符

# seq -s : -w 1 10
01:02:03:04:05:06:07:08:09:10

# seq -s '|' -w 1 10
01|02|03|04|05|06|07|08|09|10
		

等宽,前导字符用0填充

# seq -w 1 10
01
02
03
04
05
06
07
08
09
10
		

26.6.3. bc - An arbitrary precision calculator language

$ echo "4*5" | bc
		
# more calc.txt
3+2
4+5
8*2
10/4
# bc calc.txt
5
9
16
2