• awk


    练习题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:显示所有以一个DX开头的人名全名

    [root@wangna benet]# awk -F "[ :]+" '$2~/^[DX]/{print $1$2}' wang

    ZhangDandan

    ZhangXiaoyu

    WangXiaoai

     练习题5:显示所有ID号码最后一位数字是15的人的全名

    [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:显示所有人的全名,以姓,名的格式显示,如MengFeixue

    [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

  • 相关阅读:
    [UOJ#391]GEGEGE
    [GOODBYE WUXU][UOJ]
    codeforce 1110F
    [atcoder][abc123D]
    [atcoder][agc001]
    Luogu1070-道路游戏-动态规划
    Luogu 2577[ZJOI2005]午餐
    Luogu 1169 [ZJOI2007]棋盘制作
    Luogu 1273 有线电视网
    Luogu 2279 [HNOI2003]消防局的设立
  • 原文地址:https://www.cnblogs.com/wangna123/p/9873068.html
Copyright © 2020-2023  润新知