On 12/20/2011 08:03 AM, Leo M. wrote:
> Hello!
> 
> I was messing around with the "system" command in Ruby!
> That's really cool, but a question immediately sprang out while using it
> : I noticed that its output is a TrueClass, but how could I use the
> output made of directories and files as string?
> For example : if I cast a
> 
> system('ls')
> 
> it will return me a variety of directories and files. So, let's put that
> I want to scan this result to find out which directories are named how
> (with a Regexp), is there a way to read this output or the is solely a
> TrueClass?

Related to the system method is backticks (`):

output = `ls`
puts "These are the directories and files:\n#{output}"

The backticks run a command similarly to the system method, but the
output of the command you give them is captured into a string and
returned.  You can slice and dice the string as you please at that point.

Keep in mind though that there are more efficient ways to handle this
particular example than using an external command to acquire a
file/directory listing.

-Jeremy