Advertisement
eastpole

awk-ave-max.snippets

Feb 9th, 2015
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Awk 0.37 KB | None | 0 0
  1. ### YOU MUST CHANGE $99 to your field spec!
  2.  
  3.  
  4. (Works with spaces)
  5. MAX: awk 'BEGIN {max = 0} {if ($99>max) max=$99} END {print max}' data.dat
  6. AVG: awk '{sum=sum+$99} END {print sum/NR} data.dat
  7.  
  8. Works with commas:
  9. MAX: awk 'BEGIN {FS=","; max = 0} {if ($99>max) max=$99} END {print max}' data.dat
  10. AVG: awk 'BEGIN {FS=","} {sum=sum+$99} END {print sum/NR} data.dat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement