• Post Reply Bookmark Topic Watch Topic
  • New Topic

using $ in the command line in unix  RSS feed

 
Richard Shelly
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im sure everyone considers this a really dumb question, but i need to know, if its possible to use $ in the command line (the project im working on requires all input through the command line, and one of those inputs is a dollar price, an example of how the program is called was shown, with the $.). the reason i ask here is that i have to write this program in java, and i dont know unix well enough to mess around with it. (My C knowledge is slight)
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your asking what happens in a scenario like this:

export TEST="test args"

java myClass $TEST

what arguments are passed to the java program?

My experience is that the shell variable is translated before the java executable is called.

So the result is that you end up executing:

java myClass test args and that "test" and "args" are the command line inputs to the program.
 
Richard Shelly
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.
well, yes, i have a command line argument, that is skipped over by args because of the $.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To the command shell, $1 to $9 have special meaning. They represent the parameters passed to the command shell. So, if you have something like this...



The $1 and $9 will be replaced before it is passed to your program. To stop the replacement, you can put the parameter in single quotes, or use the backslash to protect the $...



Henry
 
Richard Shelly
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cheers man
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!