I have an awk script that takes the number of total eth interrupts in the system.
#!/bin/bash
FILE="/proc/interrupts"
awk 'NR==1 {
core_count = NF
print "core count: ", core_count
next
}
/eth/ {
for (i = 2; i <= 2+core_count; i++)
totals[i-2] += $i
}
END {
print "Totals"
for (i = 0; i < core_count; i++)
printf("CPU%d: %d\n", i, totals[i])
}
' $FILE
At the end of this in bash, I have the core_count and the totals array. but then, I need to use these variables, how can I use them at the rest of the script?In other words how can you globalize them?