I have a server running where I use php to run a bash script to verify certain information of a user. For example, I have a webhosting server set up, and in order to be able to
A slightly more error-proof method to check for group membership using zero char delimited fixed string grep.
if id -nGz "$USER" | grep -qzxF "$GROUP"
then
echo User \`$USER\' belongs to group \`$GROUP\'
else
echo User \`$USER\' does not belong to group \`$GROUP\'
fi
or using long opts
if id --name --groups --zero "$USER" |
grep --quiet --null-data --line-regexp --fixed-strings "$GROUP"
then
echo User \`$USER\' belongs to group \`$GROUP\'
else
echo User \`$USER\' does not belong to group \`$GROUP\'
fi