Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escape dollar sign in command line arguments

Tags:

java

args

When I pass in "$1000" through the command line and retrieve the string through args[0], it becomes "000". How can I maintain the full string in my java code?

like image 496
John Fda Avatar asked Oct 26 '15 19:10

John Fda


People also ask

How do you escape a dollar sign?

You can escape dollar signs with a backslash or with another dollar sign. So $, $$, and \$ all replace with a single dollar sign.

What does dollar sign do in command line?

The system shell prompt That dollar sign means: we're in the system shell, i.e the program that you're put into as soon as you open the Terminal app. The dollar sign is often the symbol used to signify where you can begin typing in commands (you should see a blinking cursor there).

What does the dollar sign mean in Linux command line?

Dollar sign ( $ ) means you are a normal user. hash ( # ) means you are the system administrator (root). In the C shell, the prompt ends with a percentage sign ( % ).

How do I pass a command line argument in command prompt?

Note : You pass all the command line arguments separated by a space, but if argument itself has a space then you can pass such arguments by putting them inside double quotes “” or single quotes ”.


1 Answers

I guess you're using some kind of Unix system, as '$' is the variable symbol in bash & co. Try using single quotes (e.g. java MyClass '$1000')

like image 82
secolive Avatar answered Oct 02 '22 10:10

secolive