awk 精确搜索 逐行处理
格式1:前置指令 | awk [选项] '[条件]{ 指令}'
格式2:awk [选项] '[条件]{ 指令}' 文件
指令: print 输出
选项:-F 定义分隔符
内置变量: $1第1列 $2第2列 $3 ... $0所有列 NR行号 NF列号
在/opt下的操作
[root@svr7 /]# awk '{print $1}' test.txt #输出所有行的第1列
[root@svr7 /]# awk '{print $3}' test.txt #输出所有行的第3列
[root@svr7 /]# awk '/the/{print $3}' test.txt #输出有the的行的第3列
[root@svr7 /]# awk '/the/{print NR}' test.txt #输出有the的行的行号
[root@svr7 /]# awk '{print NR}' test.txt #输出所有行的行号
[root@svr7 /]# awk '{print NF}' test.txt #输出所有行的列号
[root@svr7 /]# awk '{print $0,NR}' test.txt #输出所有列然后空格输出行号
[r