user1787282 user1787282 - 8 months ago 32
Ruby Question

Add variable in %x command in ruby

I am trying to use the %x ( ) and use a variable that i've used earlier to determine a path of a file that i want to run.

essentially i want to do something like this

location = "/home/myhome/somefolder"
%x ("ls " + location)

Is there a way to do this?


Your code works

%x ("ls " + location)


%x ("ls #{location}")