awk 反过滤不想要的列 和循环列

[root@elk_m ~]# awk '{print $0}' install.log.syslog |head -1
<86>Feb 29 02:58:28 groupadd[1598]: group added to /etc/group: name=dbus, GID=81

 

不想要的话就$num="" 并用分号结尾
[root@elk_m ~]# awk '{$2="";print $0}' install.log.syslog |head -1
<86>Feb 02:58:28 groupadd[1598]: group added to /etc/group: name=dbus, GID=81

for循环打印列

[root@elk_m ~]# awk '{for(i=2;i<NF;i++)printf("%s ",$i);printf("\n")}' install.log.syslog |head -1
29 02:58:28 groupadd[1598]: group added to /etc/group: name=dbus,

posted @ 2016-03-01 13:00  众里寻,阑珊处  阅读(930)  评论(0编辑  收藏  举报
返回顶部