awk - 数据提取和报告工具 (4) 实战

  • 原创
  • Madman
  • /
  • /
  • 0
  • 8040 次阅读

awk - 数据提取和报告工具 (4) 实战-min.png

Synopsis: awk通常用作数据提取和报告工具,例如生成格式化报告。awk语言广泛使用字符串数据类型,关联数组(即按键字符串索引的数组)和正则表达式。程序由一系列规则rule组成(程序也可能包含用户自定义的函数), 每个规则指定一个要搜索的模式pattern和匹配到模式后的动作action,模式和动作至少要指定一个。如果省略pattern,则action将应用于每一条记录(通常是每一行);如果省略action,默认是{ print $0 }将当前记录整体打印输出

awk系列:


1. 打印指定列

1. 默认以空白字符为字段的分隔符
# awk '{ print $1 }' /etc/passwd | head -n 3
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin

2. 指定FS
# awk -F: '{ print $1 }' /etc/passwd | head -n 3
root
bin
daemon

2. 格式化输出

分类: Linux
标签: awk gawk GNU
  • Enjoy Your Money Festival cw628523.tw1.ru Az
  • Activate Your Backed Money cw628523.tw1.ru e5
  • Open Your Top-Tier Prize ct695318.tw1.ru ak
  • Collect Your Digital Cash Bonus cw628523.tw1.ru DZ
  • Reveal Your Surprise Money cw628523.tw1.ru M2
  • Reach Your Voting Rights Token xdfghjkhgm.temp.swtest.ru 6F
  • Enjoy Your Chance Discovery xdfghjkhgm.temp.swtest.ru 7t
  • Activate Your Digital Belonging cw628523.tw1.ru hx
  • Receive Your Tried-and-True Prize xdfghjkhgm.temp.swtest.ru Jp
  • Take Out Your Wreath Funds ct695318.tw1.ru 0N
  • Take Your Verified Reward cw628523.tw1.ru kc
  • Take Out Your Added Advantage Extra xdfghjkhgm.temp.swtest.ru SZ
  • Win Your Royal-Top Money xdfghjkhgm.temp.swtest.ru t8
  • Get Your Speedy Reward xdfghjkhgm.temp.swtest.ru HO
  • Claim Your Zero-Deposit Reward ct695318.tw1.ru h5
  • Get Your Hands on Your Bonus ct695318.tw1.ru o5
  • Unlock Your Mystery Gift cw628523.tw1.ru 1h
  • Acquire Your Segment Prize ct695318.tw1.ru 6m
  • Access Your Stupendous Bonus cw628523.tw1.ru TF
  • Get Your Bonus with a Single Click xdfghjkhgm.temp.swtest.ru KR
  • Accept Your Group Prize ct695318.tw1.ru iq
  • Get Your Legendary Bonus ct695318.tw1.ru XL
  • Take Out Your Simulated-Game Funds cw628523.tw1.ru je
  • Redeem Your Roulette Reward cw628523.tw1.ru GS
未经允许不得转载: LIFE & SHARE - 王颜公子 » awk - 数据提取和报告工具 (4) 实战

分享

作者

作者头像

Madman

如需 Linux / Python 相关问题付费解答,请按如下方式联系我

0 条评论

暂时还没有评论.

专题系列