I need to do some error handling in the beginning of a script. If a user is not a member of a specific group then the script needs to exit.
Advertisement
Answer
group=wheel if groups | grep -q "b$groupb"; then echo member else echo "no member" exit 1 fi
or shorter:
group=wheel groups | grep -q "b$groupb" || exit 1