• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using $ in the command line in unix

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok.
well, yes, i have a command line argument, that is skipped over by args because of the $.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cheers man
 
reply
    Bookmark Topic Watch Topic
  • New Topic