-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 是一个 支持 -g 的 Bash 集成开发工具 – 马上试用
© 2020–2024 Joachim Ansorg
声明
隐私政策
许可条款