Urara-Blog/node_modules/.pnpm-store/v3/files/f5/f352cbe56e63f0d4ac2d7503d86c1d21a89a578d6cdf0752a11e8c37982b79d8a4cebb72ecc8623d4ec00a8a3dd7f26c4367368c546fa5e309d57e955c387d
2022-08-14 01:14:53 +08:00

25 lines
No EOL
459 B
Awk

#!/bin/awk -f
BEGIN {
# How many lines
lines=0;
total=0;
}
{
# this code is executed once for each line
# increase the number of files
lines++;
# increase the total size, which is field #1
total+=$1;
}
END {
# end, now output the total
print lines " lines read";
print "total is ", total;
if (lines > 0 ) {
print "average is ", total/lines;
} else {
print "average is 0";
}
}
#From https://www.grymoire.com/Unix/Awk.html