-g FILE (conditional operator)

true if the file exists and its set-group-id bit is set, i.e. the SETGID bit. false if the file does not exist or does not have the SETGID bit set.

-u is for the set-user-id bit.

Examples

Different ways to test if a file has the SETGID bit set:
1
2
3
4
test -g ~/bin/cmd && echo "SETGID set"
[ -g ~/bin/cmd ] && echo "SETGID set"
# Bash
[[ -g ~/bin/cmd ]] && echo "SETGID set"
Set the SETGID bit
1
chmod g+s /usr/local/bin/my-cmd
BashSupport Pro is a Bash IDE with support for -gtry it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal