#!/bin/bash # # File: whos.sh # # Description: Displays information about the user using the first and fifth fields # in the /etc/passwd file. The first field contains the username # (e.g., campbell) and the fifth field contains the users full # name (e.g., Andrew Campbell). You can provide a username or full name and # whos will return you the full name or username, respectively. This is # similar in spirit to the finger utility (check it out). # # Input: List of arguments can be usernames or login names. # # Output: List of usernames or login names. # # Adapted from A Practical Guide to Linux (Sobell) if [ $# -eq 0 ] then echo "Usage: whos arg needs to be [list of username or full name]" 1>&2 exit 1 fi for arg do awk -F: '{print $1, $5}' /etc/passwd | grep -i "$arg" done exit 0