[TriLUG] Scripting question

Tanner Lovelace lovelace at wayfarer.org
Thu Jan 9 16:44:16 EST 2003


On Thu, 2003-01-09 at 16:37, Stephen P. Schaefer wrote:
> userid="emma"
> awk -F":" "/^$userid/ { print \$6 }" /etc/passwd

This will still give you all users that begin with emma.  She said:

> 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?

I think you would need to add a : after userid like this:

awk -F":" "/^$userid:/ { print \$6 }" /etc/passwd

That would make sure it was an exact match.  (If anyone sees anything
wrong with that, please speak up.  I'm by no means an awk expert. :)

Cheers,
Tanner
-- 
Tanner Lovelace | lovelace(at)wayfarer.org | http://wtl.wayfarer.org/
--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--
GPG Fingerprint = A66C 8660 924F 5F8C 71DA  BDD0 CE09 4F8E DE76 39D4
GPG Key can be found at http://wtl.wayfarer.org/lovelace.gpg.asc
--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--
"Junk food is considered part of the vegetable food group, because it 
comes from a plant. A big chemical plant. In New Jersey." - Kludge
Dorsey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://www.trilug.org/pipermail/trilug/attachments/20030109/95555fb9/attachment.pgp>


More information about the TriLUG mailing list