[CentOS] RE: Slightly OT: check creation of a group

Mon Mar 1 16:09:13 UTC 2010
Frank.Brodbeck at klingel.de <Frank.Brodbeck at klingel.de>

grep medintux /etc/group || groupadd medintux

or in a if operation:

if [[ ! grep medintux /etc/group ]]
then
    groupadd medintux
fi

Regards,
Frank.

Niki Kovacs <contact at kikinovak.net>  schrieb am 01.03.2010 17:03:46:

> Hi,
> 
> I'm currently writing an install script for an application, and my 
> already limited Bash skills are a bit rusty.
> 
> I want to check if a group exists, and if it doesn't, then create it.
> 
> Only thing I found is:
> 
> if [ grep medintux /etc/group ]; then
>    continue
> else
>    groupadd medintux
> fi
> 
> Apparently I can't seem to "negate" the test, e. g. something like
> 
> if !(grep medintux /etc/group)
> 
> Any suggestions for the correct syntax here ?
> 
> Thanks,
> 
> Niki
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos