Skip to content

Instantly share code, notes, and snippets.

@jbhannah
Created June 28, 2011 20:39
Show Gist options
  • Save jbhannah/1052145 to your computer and use it in GitHub Desktop.
Save jbhannah/1052145 to your computer and use it in GitHub Desktop.
Plaintext output with header row to Ruby hash
processes = []
psef = []
`ps -ef`.lines.each { |r| psef << r }
headers = psef.shift.split
psef.each do |row|
row = row.split
p = {}
headers.each do |h|
p[h] = row.shift
end
p[headers.last] << " " + row.shift until row.empty?
processes << p
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment