Monday, March 22, 2010

Setting a variables for one command only


If you want to set a variable for one command only, you can always write the variable setting first, immediately followed by the simplecommand (don't write any ; after the assignment). This will result in the variable being set for that command only, but keeping the old value (if it had one) after the command has been executed. As an example, if you execute the code
MANPATH=/usr/man:/usr/local/man man test
will only look for the manual for test in directories /usr/man and /usr/local/man. This regardless of what value MANPATH had before the call.

No comments:

Post a Comment