#!/bin/bash #set -x progname=`basename $0` usage () { echo -e "Usage:\n\t$progname first_name \nor\n\t$progname first_name group_name\n" ; exit 1 ; } [ $# -gt 2 ] && usage [ $# -lt 1 ] && usage first_name=$1 if [ $# -eq 2 ] ; then group_name=$2 group_id=`ypmatch $group_name group | cut -d':' -f3` [ "$group_id" ] || { echo "$group_name: no such group" ; exit 2 ; } # echo "$group_name" "$group_id" ypcat passwd | grep "^[^:]*:[^:]*:[^:]*:$group_id:$first_name " |\ cut -d':' -f1,5 | tr ':' '\t' else ypcat passwd | grep "^[^:]*:[^:]*:[^:]*:[^:]*:$first_name " |\ cut -d':' -f1,5 | tr ':' '\t' fi