#!/usr/bin/awk -f
{
sum += $1
}
END {
print "sum:", sum
print "average: ", sum/NR
}
and here how to extract a given column of a file read from stdin:
#!/usr/bin/awk -f
BEGIN {
col=ARGV[1]
delete ARGV[1]
}
{
print $(col)
}
| Pete's Linux Advent Calendar 2007 | Comments? send mail to pkruse@arcor.de |
|