I am trying to calculate the CPU load of a processor using the steps found here. I managed to do this:
cat /proc/stat | head -n 1 | awk '{print ($5+$6, $2+$3+$4+$7+$8+$9)}' | awk '{print($1,$1+$2)}'
This gives me the values I need. However, I need to calculate the same values a second later and then use both of these results to calculate the final load. That means, that I need to do something like this:
cat /proc/stat | calculate something | awk '{print($1,$1+$2)}' ; sleep for a second; calculate again; use both of the results
Is there a way for me to save the variables $1 and $1+$2 in the first awk call, so that I can use them later? I cannot use a bash script, it needs to be done in a command line.