求详解释一个shell脚本
# /bin/sh
# hist_record.sh
# This script is often to write in /etc/profile.
# This script could record history input and send mail to root.
RMIP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
TIME=`date +%Y%m%d.%H:%M.%S`
if [ "$RMIP" = "" ]
then
RMIP=`hostname`
fi
LOGS="/tmp/.hist/$TIME.$USER.$RMIP.hist"
HOST=`/bin/hostname`
if [ ! -d /tmp/.hist ]
then
mkdir /tmp/.hist
chmod 777 /tmp/.hist
fi
script -q $LOGS && mail -s "$TIME, $USER FROM $RMIP LOGIN $HOST" root < $LOGS