[CentOS] Slightly OT: check creation of a group
l.wandrebeck at gmail.com
Mon Mar 1 16:08:16 UTC 2010
2010/3/1 Niki Kovacs <contact at kikinovak.net>:
> 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
> groupadd medintux
> 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 ?
Why don't you use groupadd -f ? It will not override the group if it
already exists, and shortens the code :)
More information about the CentOS