$n 当前记录的第n个字段,字段间由FS分隔
$1表示第一列,$表示第二列,$0表示全部列数,NF显示每行的列数,$NF显示最后一列的数据,NR==n显示第n行数的数据 ,awk 'END{print}' 显示最后一行的数据
[root@VM-4-13-centos awk]# cat cj.txt A B C D 30 40 50 60 30 40 50 30 40 50 60 30 40 [root@VM-4-13-centos awk]# cat cj.txt |awk '{print $1}' A 30 30 30 30 [root@VM-4-13-centos awk]# cat cj.txt |awk '{print $2}' B 40 40 40 40 [root@VM-4-13-centos awk]# cat cj.txt |awk '{print $0}' A B C D 30 40 50 60 30 40 50 30 40 50 60 30 40 [root@VM-4-13-centos awk]# cat cj.txt |awk '{print NF}' 4 4 3 4 2 [root@VM-4-13-centos awk]# cat cj.txt |awk '{print $NF}' D 60 50 60 40 [root@VM-4-13-centos awk]# cat cj.txt |awk 'NR==1{print }' A B C D [root@VM-4-13-centos awk]# cat cj.txt |awk 'END{print }' 30 40
标签:cj,END,centos,30,40,awk,NF,txt From: https://www.cnblogs.com/joyware/p/17107810.html