shell - Linux command to sum integers, one per line? - Stack Overflow - http://unread.posterous.com/shell-l...
Apr 1, 2011
from
awk '{s+=$1} END {print s}' mydatafile
via stackoverflow.com
Sometimes this is very handy ;)
(ie - netstat -an | grep ':PORT ' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n | awk '{gsub(/^ +| +$/,"")}1' | cut -f 1 -d ' ' | awk '{s+=$1} END {print s}')
Permalink | Leave a comment »
- Martynas