Created
June 28, 2011 20:39
-
-
Save jbhannah/1052145 to your computer and use it in GitHub Desktop.
Plaintext output with header row to Ruby hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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