1、创建测试数据
[root@centos7 test2]# cat > a.txt i s g z e q d k i p m h y u t e ^C [root@centos7 test2]# ls a.txt [root@centos7 test2]# cat a.txt i s g z e q d k i p m h y u t e
2、提取列数为3的行
[root@centos7 test2]# cat a.txt i s g z e q d k i p m h y u t e [root@centos7 test2]# awk 'NF == 3' a.txt z e q m h y
3、删除列数为3的行
[root@centos7 test2]# cat a.txt i s g z e q d k i p m h y u t e [root@centos7 test2]# awk 'NF != 3' a.txt i s g d k i p u t e