1 2 3 4 5 6 7 8 9 10 11 12 13
#!/usr/bin/env bash table=$(cat input.txt | sort | uniq -c | sort) most=$(tail -n3 <<< "$table") least=$(head -n3 <<< "$table") calc(){ awk 'BEGIN { p = 1 } { p *= $2 } END { print p }' } calc <<< "$most" calc <<< "$least"