awk sum numbers after a separator -
i need simple awk calculate sum of number @ end of file looks this:
/z02/abcd/stuff/abc_def_02/count/abc_def_02_abcde66.log.20120605_101201_015.log.gz:28 /z02/abcd/stuff/abc_def_02/count/abc_def_02_abcde66.log.20120605_101202_015.log.gz:28 /z02/abcd/stuff/abc_def_02/count/abc_def_02_abcde66.log.20120605_101203_015.log.gz:28 /z02/abcd/stuff/abc_def_02/count/abc_def_02_abcde66.log.20120605_101204_015.log.gz:28
so numbers after ":" need added together
echo "....." | awk '-f:' '{total+=$nf}end{print "sumtotal=" total}'
you can, of course, leave out "sumtotal=" part, depending on needs.
i hope helps.
Comments
Post a Comment