LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   *** how to set up a variable in Linux? *** (https://www.linuxquestions.org/questions/linux-newbie-8/%2A%2A%2A-how-to-set-up-a-variable-in-linux-%2A%2A%2A-589751/)

meili100 10-05-2007 03:15 PM

*** how to set up a variable in Linux? ***
 
I am a newbie. I know this is a little off-stream of programming, but it is the problem when I tried to program in linux. I wonder if there is a way to set up a variable, say $VAR = /home/root, so that I can use
cd $VAR
instead of
cd /home/root

puntjuh 10-05-2007 03:26 PM

You are looking for this :).

http://www.ee.surrey.ac.uk/Teaching/Unix/unix8.html

You can set them temporarily or too last for ever.

ankit_mcgill 10-05-2007 08:31 PM

on the prompt type

VR=/home/root

then CD $VAR should work like cd /home/root

note: this variable is only valid in the shell u defined it in. its a local variable

to make it permanent you would have to define it in ~/.bashrc


All times are GMT -5. The time now is 04:34 PM.