#!/usr/bin/awk -f #Sums a column from a given file. The filename # must be the first arg, and the column the second one # hence it can only be used in a pipeline by using - # to indicate stdin as the input 'file'. # #Note the use of 'delete ARGV[2]' to stop awk thinking #that we are passing in a list of files to process. BEGIN { i=ARGV[2] ; delete ARGV[2] ; count=0 } { sum += $i ; count ++ } END { printf "%5.2f\n", sum }