|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
|
Re: [PLUG] check for existing user
|
> That was my first thought, but then grep returns the lines which that
> appears, and what if it is in another field besides the first field? (Like
> name or something) - (ok i answered my own question, use a regexp, but im
> trying to make this really simple! and I kinda forget how to do regexps
> anyway...)
> I was thinking of just using the command id, but for either grep or id,
> how do I make a variable equal to true or false depending on what grep or
> another command returns? (in bash)
DISCLAIMER: I am not a shell scripter (yet).
I'm not sure how bash does it, but I know that in C, perl, and the like,
"truth" is defined by something != (null or zero). Couldn't you do:
if ("grep /etc/passwd -e $USERNAME")
$USER_EXISTS=1;
do this;
fi
(I'm not sure if the quotes should be double-quotes, single-quotes, or
back-ticks.) The syntax above is probably horribly broken (resembling C
more than shell scripting), but it gives the basic idea of what I'm
thinking. If this won't work, I'd love to know how to do it.
Bill
--
"Because they know that all they sold you was a guaranteed POS! Look, if
you want me to take a dump in a box and mark it 'guaranteed', I will. I got
spare time."
-Chris Farley (on Microsoft?), _Tommy Boy_
______________________________________________________________________
Philadelphia Linux Users Group - http://plug.nothinbut.net
Announcements - http://lists.nothinbut.net/mail/listinfo/plug-announce
General Discussion - http://lists.nothinbut.net/mail/listinfo/plug
|
|