[TriLUG] Scripting question
Janyne Kizer
janyne_kizer at ncsu.edu
Thu Jan 9 16:32:43 EST 2003
Now I wish that I had posted sooner. I think that I have it working
now. Isn't that always the case? Right after I ask for help I have an
"ah ha!" moment...
homedir=`grep "\<$userid\>" /etc/passwd | awk -F":" {'print $6'}`
Thanks for listening!
Janyne Kizer wrote:
>
> 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
> _______________________________________________
> TriLUG mailing list
> http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ:
> http://www.trilug.org/~lovelace/faq/TriLUG-faq.html
--
Janyne Kizer
Systems Programmer Administrator
NC State University, College of Agriculture & Life Sciences
Extension Information Technology
More information about the TriLUG
mailing list