#!/bin/bash
#===============================================================================
#
#          FILE: mode
#
#         USAGE: mode
#
#   DESCRIPTION: Print value that occurs most frequently from the Standard Input
#
#          BUGS:  ---
#        AUTHOR: rickz (Rick Zhang), xlrickz@gmail.com
#       COMPANY: X-LEGEND Entertainment Corp.
#       CREATED: Wed May  2 16:40:08 KST 2012
#      REVISION: 1.0
#
#          TODO:
#
#===============================================================================

#set -o nounset                              # Treat unset variables as an error
#set -m                                      # Enable job control

INPUT="$(cat)"

MOST_TIMES="$(cat <<< "$INPUT" | sort | uniq -c | sort -gr | head -1|awk '{print $1}')"

cat <<< "$INPUT" | sort | uniq -c | sort -gr | awk "\$1 == $MOST_TIMES" | awk '{print $NF}'
