Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Etc::Group.each

Etc::Group.each { |group| block } → obj
Etc::Group.each → Enumerator

Iterates for each entry in the /etc/group file if a block is given.

If no block is given, returns the Enumerator.

The code block is passed a Group struct.

Example:

Example
require 'etc'

Etc::Group.each {|g|
  puts g.name + ": " + g.mem.join(', ')
}

Etc::Group.collect {|g| g.name}
Etc::Group.select {|g| !g.mem.empty?}
also in 4.1 · 4.0 · 3.4 · 3.3