TAGS :Viewed: 7 - Published at: a few seconds ago

[ $ symbol is stripped from command line ]

I'm using the command line:

$ruby run.rb add $10000

and the second argument $10000 appears to be passed to ruby as 0000. How do I prevent $1 from being stripped?

Answer 1


You have to escape it on the shell. The shell interprets $1 as a variable. This should work:

$ ruby run.rb add \$1000

You could also single-quote the string:

$ ruby run.rb add '$1000'