From: Karl Bennett Date: 2006-04-06T09:11:14+09:00 Subject: HOWTO Use Veriables inside of Regexp and Commands? Hi, I've just started using Ruby and am LOVING IT! :D For my job I need to do allot of shell scripting but have been getting very annoyed at its limitations. So I am now looking to Ruby to replace it. The thing is I need to be able to run a command say "ls" with a variable say "directory". Heres an example of what I would do in shell script. $directory="/tmp" ls $directory Now in Ruby I have to use the backquotes for commands right? So if I create a variable directory in Ruby how do I get it's contents to be executed in the command or evaluated in a regular expression? For example: directory = "/tmp" puts `ls directory` puts /directory/ I know the above is wrong and both will just evaluate the word directory not the variables contents. So how do I get the contents in there? Thank you very much for you help. -- Posted via http://www.ruby-forum.com/.