1.[4@izuf60jasqavbxb9efockpz ~]$ echo $PATH | awk 'BEGIN{FS=":"}''{print $0}'
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/4/.local/bin:/home/4/bin:/home/16116374/test
[4@izuf60jasqavbxb9efockpz ~]$ echo $PATH | awk 'BEGIN{RS=":"}''{print $0}'
/usr/local/bin
/usr/bin
/usr/local/sbin
/usr/sbin
/home/4/.local/bin
/home/4/bin
/home/4/test
RS会根据制定的分隔符换行
2.[4@izuf60jasqavbxb9efockpz ~]$ echo $PATH | awk 'BEGIN{FS=":"}''{print $0}'
/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/4/.local/bin:/home/4/bin:/home/4/test
3.[4@izuf60jasqavbxb9efockpz ~]$echo $PATH | awk 'BEGIN{FS=":"}''{print $1}'
/usr/local/bin
科学计算与词典使用
4.awk 'BEGIN{print 3*7}'
21
5.echo | awk '{print 3*7}'
21
6.awk 'BEGIN{printf "%.3f ",3/7}'
0.429
7.awk 'BEGIN{printf "%.f ",3/7}'
0
8.awk 'BEGIN{printf "%.1f ",3/7}'
0.4
9.seq 10 2 20
10
12
14
16
18
20
步数为2
10.seq 10 2 20 | awk '{sum+=$1}{print sum}'
10
22
36
52
70
90
11.seq 10 2 20 | awk '{sum+=$1}{print sum,NR}'
10 1
22 2
36 3
52 4
70 5
90 6
12.seq 10 2 20 | awk '{sum+=$1}{print sum/NR}'
10
11
12
13
14
15
13.seq 10 20 | awk '$1>19'
20
大于19
14. seq 10 2 20 | awk '$1>14 {data[NR]=$1}{for (k in data) print data[k]}'
16
16
18
16
18
20
15.seq 10 2 20 | awk '$1>14 {data[NR]=$1}END{for (k in data) print data[k]}'
16
18
20