Re: Slightly OT: check creation of a group

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Mon, 2010-03-01 at 17:03 +0100, Niki Kovacs wrote:
> 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 ?
> 

Try this:

grep -q medintux /etc/group || groupadd medintux

> Thanks,
> 
> Niki
> _______________________________________________
> CentOS mailing list
> CentOS@xxxxxxxxxx
> http://lists.centos.org/mailman/listinfo/centos
-- 
Ron Loftin                      reloftin@xxxxxxxxxxxx

"God, root, what is difference ?"       Piter from UserFriendly

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux