Jason Wade
Jason Wade

Reputation: 87

$ 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?

Upvotes: 0

Views: 31

Answers (1)

mipadi
mipadi

Reputation: 410672

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'

Upvotes: 4

Related Questions