You're already running AWK, make it do the additions
top | grep root | awk '{ sum += $10 }
END {print sum}'
Yes, you need that newline in the command
> p.s - why when i run that command i need to press q to get the result?
Because 'top' is an interactive program?
You'd have to read the manual to see if there's a "do it once and quit" option.
But I'd use 'ps' if it works.
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Offline 7,164 posts
since Dec 2005