How to filter interfaces in snmp output

Hi all,
This is the output of snmpwalk:
Code:
    snmpwalk -c public -v2c localhost .1.3.6.1.2.1.2
    IF-MIB::ifNumber.0 = INTEGER: 5
    IF-MIB::ifIndex.1 = INTEGER: 1
    IF-MIB::ifIndex.2 = INTEGER: 2
    IF-MIB::ifIndex.3 = INTEGER: 3
    IF-MIB::ifIndex.4 = INTEGER: 4
    IF-MIB::ifIndex.5 = INTEGER: 5
    IF-MIB::ifDescr.1 = STRING: gbeth0
    IF-MIB::ifDescr.2 = STRING: gbeth1
    IF-MIB::ifDescr.3 = STRING: gbeth2
    IF-MIB::ifDescr.4 = STRING: gbeth3
    IF-MIB::ifDescr.5 = STRING: defloopback

I want to filter some interfaces. For example I want snmp filter defloopback and just shows gbeth0 to gbeth3.
How should I do this?

Thanks all
 
Try using snmpwalk ... | awk -F "[. ]" '$2 ~ /[1234]/ {print $0}'

This is partially your solution, because snmpwalk output more lines and awk is only selecting lines which 2nd token is 1 to 4 (tokens separated by point or space)
 
Back
Top