#!/bin/sh password_file=mypass # Get the last line from the password file lastline=`tail -1 ${password_file}` # Set the inter-field separator to the colon (:). this will allow us to parse # the password file entry that uses colons to separate fields. IFS=":" # Set the fields in the password file entry to the parameters 1-7 set ${lastline} # Don't forget to set ifs back to blank as soon as possible. IFS=" " username=$1 passwd=$2 userid=$3 groupid=$4 fullname=$5 homedir=$6 shell=$7 set ${fullname} # number the names we got from fullname counter=1 for x in $* do echo ${counter} $x counter=`expr ${counter} + 1` done firstname=$1 secondname=$2 thirdname=$3 if [ -z $thirdname ] then echo "No middle name" lastname=${secondname} else lastname=${thirdname} middlename=${secondname} fi # list all the names, just so that we can be sure that we have the correct # fields. echo "username is ${username}" echo "password is ${passwd:-*****no password specified!!!!!*****}" echo "userid is ${userid}" echo "groupid is ${groupid}" echo "full name is ${fullname}" echo "first name is ${firstname}" if [ ! -z ${middlename} ] then echo "middle name is ${middlename}" fi echo "last name is ${lastname}" echo "home directory is ${homedir}" echo "shell is ${shell}"