练习题1:显示姓Zhang的人的第二次捐款金额及她的名字
[root@wangna benet]# awk -F "[ :]+" '/^Zhang/{print $1$2,$5}' wang
练习题2:显示Xiaoyu的名字和ID号码
[root@wangna benet]# awk -F "[ :]+" '/Xiaoyu/{print $1$2,$3}' wang
ZhangXiaoyu 390320151
[root@wangna benet]# awk -F "[:]+" '/Xiaoyu/{print $1}' wang
Zhang Xiaoyu 390320151
[root@wangna benet]# awk -F ":" '/Xiaoyu/{print $1}' wang
Zhang Xiaoyu 390320151
[root@wangna benet]# awk -F "[ :]+" '$2~/Xiaoyu/{print $1$2,$3}' wang
ZhangXiaoyu 390320151
练习题3:显示所有以41开头的ID号码的人的全名和ID号码
[root@wangna benet]# awk -F "[ :]+" '$3~/^41/{print $1$2,$3}' wang
ZhangDandan 41117397
LiuBinbin 41117483
练习题4:显示所有以一个D或X开头的人名全名
[root@wangna benet]# awk -F "[ :]+" '$2~/^[DX]/{print $1$2}' wang
ZhangDandan
ZhangXiaoyu
WangXiaoai
练习题5:显示所有ID号码最后一位数字是1或5的人的全名
[root@wangna benet]# awk -F "[ :]+" '$3~/[1,5]$/{print $1$2}' wang
ZhangXiaoyu
WuWaiwai
WangXiaoai
LiYoujiu
LaoNanhai
[root@wangna benet]# awk -F "[ :]+" '$3~/[1,5]$/{print $1$2,$3}' wang
ZhangXiaoyu 390320151
WuWaiwai 70271111
WangXiaoai 3515064655
LiYoujiu 918391635
LaoNanhai 918391635
练习题6:显示Xiaoyu的捐款,每个值都有以开头。如520200135
[root@wangna benet]# awk -F "[ :]+" '$2~/Xiaoyu/{print $2,"$"$4"$"$5"$"$6}' wang
Xiaoyu $155$90$201
[root@wangna benet]# awk -F "[ :]+" '$2~/Xiaoyu/{print $1$2,"$"$4"$"$5"$"$6}' wang
ZhangXiaoyu $155$90$201
练习题7:显示所有人的全名,以姓,名的格式显示,如Meng,Feixue
[root@wangna benet]# awk -F "[ ]+" '{print $1","$2}' wang
Zhang,Dandan
Zhang,Xiaoyu
Meng,Feixue
Wu,Waiwai
Liu,Binbin
Wang,Xiaoai
Zi,Gege
Li,Youjiu
Lao,Nanhai
[root@wangna benet]# awk -F "[ :]+" '{print $1","$2}' wang
Zhang,Dandan
Zhang,Xiaoyu
Meng,Feixue
Wu,Waiwai
Liu,Binbin
Wang,Xiaoai
Zi,Gege
Li,Youjiu
Lao,Nanhai