variable

Bash GROUPS — group membership array

Array of group identifiers for the current user. Assignment has no effect while special; unsetting it removes special behavior. Membership is not a complete permission decision because ACLs and filesystem policy may matter. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): numeric groups.

Formal Syntax & Structure

bash syntaxbash
${GROUPS}

Return Value

indexed array

Numeric group identifiers.

Working Example

Example Snippetbash
for g in "${GROUPS[@]}"; do [[ $g =~ ^[0-9]+$ ]] || exit 1; done(( ${#GROUPS[@]} > 0 )) || exit 1printf 'numeric groups\n'
Bash Reference