我有以下格式的命令输出:
Ethernet STATISTICS (ent0) :
Device Type: 2-Port 10/100/1000 Base-TX PCI-X Adapter (14108902)
Hardware Address: 00:09:6b:6e:5d:50
Transmit Statistics: Receive Statistics:
-------------------- -------------------
Packets: 0 Packets: 0
Bytes: 0 Bytes: 0
Interrupts: 0 Interrupts: 0
Transmit Errors: 0 Receive Errors: 0
Packets Dropped: 0
ETHERNET STATISTICS (ent1) :
Device Type: 2-Port 10/100/1000 Base-TX PCI-X Adapter (14108902)
Hardware Address: 00:09:6b:6e:5d:50
Transmit Statistics: Receive Statistics:
-------------------- -------------------
Packets: 30 Packets: 0
Bytes: 1800 Bytes: 0
Interrupts: 0 Interrupts: 0
Transmit Errors: 0 Receive Errors: 0
Packets Dropped: 0 Packets Dropped: 0
Bad Packets: 0
我需要将与 ent0 关联的传输数据包数和与 ent1 关联的传输数据包数保存到变量中。我需要使用 awk 来完成这项任务,虽然我知道如何提取数据包的数量,但我不知道如何将它与上面几行列出的适配器(ent0 或 ent1)相关联。似乎我需要使用某种嵌套循环,但不知道如何在 awk 中执行此操作。