Ruby execute shell command and get array

bash, ruby, shell

Solution

Sure, depending on the output you could just split it. For example:

lines = `ls`.split

This solution is independent of the method you're using to execute the program. As long as you get the complete string you can `split` it.

Problem

I'm getting a string of few lines from the shell. Is it possible to get an `Array` with each line being its element?

Original source