awk for multiple pattern search&同时从输出中删除第一行

时间:2016-04-13 11:21:33

标签: awk

我需要删除要用awk删除的输出的第一行。以下是命令和输出已显示..

bash-3.2$ ldaplist -l hosts mylv104 | awk -F: '/cdsLocationDetail|.seemac.com|ipHostNumber/ {print $2}'
 cn=mylv104+ipHostNumber=196.2.16.181,ou=hosts,ou=corp,ou=services,o=seemac.com
 R3/C12/U21
 mylv104.seemac.com
 196.2.16.181

虽然我用另一个带管道的awk但是我不想要它...

bash-3.2$ ldaplist -l hosts mylv104 | awk -F: '/cdsLocationDetail|.seemac.com|ipHostNumber/ {print $2}' |awk 'NR>1'

 R3/C12/U21
 mylv104.seemac.com
 196.2.16.181

1 个答案:

答案 0 :(得分:1)

您可以在匹配线时设置标记,如下所示:

ldaplist -l hosts mylv104 | awk -F: '/cdsLocationDetail|.seemac.com|ipHostNumber/{if(!firstMatch){firstMatch=1;next;}print $2}'