How To
Summary
Here is a useful script I picked up off the internet some time ago.
Objective
It finds the sum of a particular column, you use it as a filter, ie: pipe something into it and it gives you an output.
Environment
# SumCol - sum of a column
#
#SYNOPSIS
# SumCol N <data
#
#DESCRIPTION
# Add up column N1 of stdin. If you pipe the output of "ls -l" to
# this, it will add up the sizes, which are in column 4, our
# default. You can specify the column for other kinds of files.
#
#BUGS
# There's a better version available in perl; awk is obsolete.
#
#AUTHOR
# John Chambers <jc@trillian.mit.edu>
if [ $# -lt 1 ];then set 4;fi
awk '{s += $'$1'} END {print s}'
Steps
If you want to see it in use see these blog entries:
Additional Information
Document Location
Worldwide
[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"HW1A1","label":"IBM Power Systems"},"Component":"","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]
Was this topic helpful?
Document Information
Modified date:
03 May 2021
UID
ibm11118127