0

When i pass name = a.txt, then ls should take a.txt as input and provide correct output. This is not happening. Tried all possible combinations of quotes. I am a Ruby novice so plz excuse my naivety.

  puts "Enter name: "
  name = gets
  name.chomp!
  puts `ls  + name`

2 Answers 2

3

You should use

puts `ls #{name}`

The #{} form can be used to insert the result of a ruby expression inside a string.

Sign up to request clarification or add additional context in comments.

Comments

2

You need to tell the interpreter that name is a variable and that you don't just want the string "name", but rather the result of interpreting the value, which you do via #{VAR_NAME}.

puts `ls #{name}`

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.