-
-
Save ChicagoDev/4eda236355d11d0fb388d72331865d8e to your computer and use it in GitHub Desktop.
Awk scripts for total/average/max/min. All numbers come in on STDIN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
BEGIN { TOTAL=0 } | |
{ TOTAL = TOTAL + $1 } | |
END { print TOTAL/NR } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
{ if( MAX == "" || $1 > MAX ) { MAX=$1 } } | |
END { print MAX } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
{ if( MIN == "" || $1 < MIN ) { MIN=$1 } } | |
END { print MIN } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
BEGIN { TOTAL=0 } | |
{ TOTAL = TOTAL + $1 } | |
END { print TOTAL } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment