Skip to content

Instantly share code, notes, and snippets.

@kitsuyui
Created February 12, 2015 12:03
Show Gist options
  • Save kitsuyui/cd5482a8e0a1487eb864 to your computer and use it in GitHub Desktop.
Save kitsuyui/cd5482a8e0a1487eb864 to your computer and use it in GitHub Desktop.
$ awk '{s += $1} END {print s}' < sample-1.txt
18
$ awk '{a += $1; b += $2} END {print a, b}' < sample-2.txt
10 26
$ sort -n < sample-3.txt | uniq -c
7 a
3 b
1 c
$ sort -n < sample-3.txt | uniq -c | awk '{a+=$1; print $2, $1} END {print "計”, a}'
a 7
b 3
c 1
計 11
1 5
2 6
3 7
4 8
a
a
a
a
a
a
a
b
b
b
c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment