#! /bin/bash # # Filename: whois # # From Mark Sobell's Red Hat Linux book. Adapted by Br. David Carlson. # # Date: March 26, 2007 # # This script, when given usernames, fullnames, or partial names as parameters, # prints the usernames and fullnames for all accounts that match. if [ $# -eq 0 ] then echo "Syntax: whois " 1>&2 exit 1 fi # Produce a temp file of all usernames and fullnames: temp="/tmp/whois.$$" cat /etc/passwd | cut -d':' -f1,5 > "$temp" # Look for matches: for user in "$@" do grep -i "$user" "$temp" done rm -f "$temp" exit 0