Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 386 Bytes

calc.md

File metadata and controls

23 lines (16 loc) · 386 Bytes
  1. 列求和
awk 'BEGIN { sum = 0 }{ sum += $1 } END {print sum}' data.txt
  1. 求平均
awk 'BEGIN { sum = 0 }{ sum += $1 } END {print sum/NR}' data.txt
  1. 求最大值
awk 'BEGIN { max = 0 }{ if ($1 > max) max = $1 fi } END {print max}' data.txt
  1. 求最小值
awk 'BEGIN { min = 1999999 }{ if ($1 < min) min = $1 fi } END {print min}' data.txt