Skip to content

Instantly share code, notes, and snippets.

@jcf
Created December 29, 2008 02:12
Show Gist options
  • Save jcf/41131 to your computer and use it in GitHub Desktop.
Save jcf/41131 to your computer and use it in GitHub Desktop.
We list UIDs so why not PrimaryGroupIDs in an equally slow fashion?!
#!/usr/bin/env ruby -wKU
groups = %x(dscl . -list /Groups).split("\n")
gids = []
groups.each do |group|
gids += [%x(dscl . -read /Groups/#{group} PrimaryGroupID).split[-1].to_i]
end
puts gids.sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment