[TriLUG] Scripting question

Janyne Kizer janyne_kizer at ncsu.edu
Thu Jan 9 16:22:54 EST 2003


I am trying to get a list of home directories for regular users in a
script.  The problem that I am running into is we have some cases where
users with similar IDs are on the system.  For example, sa, saclark and
sange or edware and dware.  On our test system we have emma and emma60. 
Anyway, I am trying to do something similar to this:

for userid in `cat /etc/passwd | awk -F":" {'print $1'} | grep -xv
"^the-stuff-we-don't-want"
homedir=`grep $userid /etc/passwd | awk -F":"  {'print $6'}`

and of course it is returning two homedirs for emma (/home/emma and
/home/emma60).  How can I get it to do an exact match?  From the command
line this works:

grep '\<emma\>' /etc/passwd

but I must be doing something wrong with the escaping when I put it into
a script.

Any suggestions would be appreciated!
-- 

Janyne Kizer
Systems Programmer Administrator
NC State University, College of Agriculture & Life Sciences
Extension Information Technology



More information about the TriLUG mailing list