The following command has the following output:
[xr-vm_node0_RP0_CPU0:~]$show_snmp_interface_notif -x .*
ifName : Null0 ifIndex: 1
ifName : MgmtEth0/RP0/CPU0/0 ifIndex: 2
ifName : Loopback0 ifIndex: 5
ifName : Bundle-Ether25 ifIndex: 6
ifName : Bundle-Ether42 ifIndex: 7
ifName : Optics0/0/0/0 ifIndex: 8
ifName : Optics0/0/0/1 ifIndex: 9
...
ifName : HundredGigE0/0/1/3 ifIndex: 92
ifName : HundredGigE0/0/1/2 ifIndex: 93
ifName : HundredGigE0/0/1/1 ifIndex: 94
ifName : HundredGigE0/0/1/0 ifIndex: 95
ifName : Loopback1 ifIndex: 96
I would like to extract the lines where the last column equals any of the numbers below.
2 6 7 52 53 54 55 56 57 89 90 91
Attempts: 1) Confirmed that above elements were stored and printed via array[i] correctly
[xr-vm_node0_RP0_CPU0:~]$show_snmp_interface_notif -x .* | awk 'BEGIN{split("2 6 7 52 53 54 55 56 57 89 90 91",array)}; END {for (i in array) print array[i]}'
2
6
7
52
53
54
55
56
57
89
90
91
2) Verified that $NF matches the last column
[xr-vm_node0_RP0_CPU0:~]$show_snmp_interface_notif -x .* | awk '{print $NF}'
1
2
5
6
7
8
9
10
11
12
...
92
93
94
95
96
3) Wrote the following awk statement which does not print anything. I suspect the print statement is incorrect. We need to pull out the complete line if the last column matches any of the specified elements in array[i].
[xr-vm_node0_RP0_CPU0:~]$show_snmp_interface_notif -x .* | awk 'BEGIN{split("2 6 7 52 53 54 55 56 57 89 90 91",array)}; END {for (i in array); if(array[i]==$NF) { print $i }}'
[xr-vm_node0_RP0_CPU0:~]$show_snmp_interface_notif -x .* | awk 'BEGIN{split("2 6 7 52 53 54 55 56 57 89 90 91",array)}; END {for (i in array); if(array[i]==$NF) { print i }}'