Listing 2: idleuser Script

#!/bin/sh
#
#       idleuser
#
#       Show users idle longer than specified days.
#
#       Copyright 1994, Lawrence S Reznick

if [ $# -ne 1 ]
then
        echo "Usage:    $0 days\n"
        echo "Show users logged in & idle for longer than the specified days."
        exit 1
fi

finger |
cut -c-9,35-40 |
egrep "[0-9]+d" |
awk '{
        if ( $2 + 0 >= days ) {
                print $1, "(" $2 ")";
        }
}' days=$1

