参考:Shell中如何按列求和?
使用awk按列求和
[linux@test /tmp]$ awk '{sum += $1};END {print sum}' test
[linux@test /tmp]$ awk '/aaa/ {sum += $2};END {print sum}' test
参考:Shell中如何按列求和?
使用awk按列求和
[linux@test /tmp]$ awk '{sum += $1};END {print sum}' test
[linux@test /tmp]$ awk '/aaa/ {sum += $2};END {print sum}' test