Tuesday, February 4, 2014

Shell - Calculate the sum on Shell.

@ $9 is a place where there is numbers in T.S.V.
$ cat ./logName.log | grep needWord | gawk -F'\t' '{print $9}' > sum.txt

@ Sum the values from the file.
$ awk '{s+=$1} END {print s}' ./sum.txt

No comments:

Post a Comment