#! /bin/sh

# Question 2, shell programming assignment, 2003.
user=root
[ $# -eq 1 ] && user=$1

for wtmp in /var/log/wtmp*;do
    last -R -f $wtmp $user
done \
| egrep -v '^\s*$|^wtmp.* begins' \
| awk '{$1="";$2="";print}' \
| cut -b 3-12 \
| uniq -c
