I'm trying to write a command that gives me some information about a linux system. The command should be a one liner. It should represent the total amount of interrupts, processes and context-switches.
I'm quite new to the linux world, so this isn't an easy thin for me. So far, I found this:
cat /proc/stat | grep -E 'ctxt|intr|processes' | \
perl -nle 'if ($line == /^intr (.*)/) {print $_} else {print $1}'
The problem is in the last part, the else. I'm not interessed in the value of $1, but I should know the sum of the items in $1.
$1 should contain something like:
8522774 17 6 0 0 0 0 2 0 1 0 1435117 21 103 0 84742 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
But I've no idea how I could get the sum of all these numbers. I believe I should pass it to bc, but I've no idea how to manage this.