I'm new to bash and want to improve. I need to learn reading specific text from a file or from output of a command.For example I want to sum of the total ethernet interrupt numbers of each core of the computer from /proc/interrupts file.The content of the file is:
CPU0 CPU1 CPU2 CPU3
0: 142 0 0 0 IO-APIC-edge timer
1: 1 0 1 0 IO-APIC-edge i8042
4: 694 18 635 19 IO-APIC-edge serial
7: 0 0 0 0 IO-APIC-edge parport0
9: 0 0 0 0 IO-APIC-fasteoi acpi
12: 1 1 0 2 IO-APIC-edge i8042
14: 0 0 0 0 IO-APIC-edge ide0
19: 0 0 0 0 IO-APIC-fasteoi uhci_hcd:usb3
23: 0 0 0 0 IO-APIC-fasteoi ehci_hcd:usb1, uhci_hcd:usb2
46: 347470 119806 340499 108227 PCI-MSI-edge ahci
47: 33568 45958 46028 49191 PCI-MSI-edge eth0-rx-0
48: 0 0 0 0 PCI-MSI-edge eth0-tx-0
49: 1 0 1 0 PCI-MSI-edge eth0
50: 28217 42237 65203 39086 PCI-MSI-edge eth1-rx-0
51: 0 0 0 0 PCI-MSI-edge eth1-tx-0
52: 0 1 0 1 PCI-MSI-edge eth1
59: 114991 338765 77952 134850 PCI-MSI-edge eth4-rx-0
60: 429029 315813 710091 26714 PCI-MSI-edge eth4-tx-0
61: 5 2 1 5 PCI-MSI-edge eth4
62: 1647083 208840 1164288 933967 PCI-MSI-edge eth5-rx-0
63: 673787 1542662 195326 1329903 PCI-MSI-edge eth5-tx-0
64: 5 6 7 4 PCI-MSI-edge eth5
I need to read all of the numbers of interrupts with "eth" keyword and then find the sum of them for each CPU core(whateve the CPU core name is). For example for CPU0:33568+0+1+28217... What is suitable for this? Must I use awk or sed for regex and how?