Home | 簡體中文 | 繁體中文 | 雜文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 作品與服務 | Email

24.6. Numeric

24.6.1. 數值運算

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

24.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
		

24.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
		
comments powered by Disqus