For example there is a long path that I cd to very often. How do I store the path in a variable so that I can use it everytime?
For example: I wan to be able to do this
cd $path
instead of
cd /a/b/c/d/e/f
everytime.
|
assuming you really want csh/tcsh syntax (as you have tagged your question), put this
to your .tcshrc after that you are able to do
|
|||
|
|
|
In Bash shell:
And you don't want to use $path. That's a special variable. |
|||||||||||||||
|
|
It's not likely that you need your variable in the environment. So, in csh instead of
or in Bash, instead of
|
|||||
|
|
Use export. export your_path="/a/b/c/d/e/f" cd $your_path If you want it to persist through logins, you're going to need to edit it into your .profile file. |
|||||||||||
|
|
If you just want to use the path for one session, set the variable as usual
You can then If you're interested in the variable being available to processes run from the shell session you should set it in your environment
If what you want is for the variable to be available to every session, instead of just the current one, you will need to set it in your shell run control.
Then add the |
|||
|
|
|
For csh you probably want to use cdpath . For bash, use CDPATH instead. For example (bash):
You can also add more colon delimited directory targets. Keep the leading colon so CDPATH checks your current working directory first! |
||||
|
|
csh) or the more common Borne / Bash Shell (shandbashrespectively)? – mctylr Mar 9 '10 at 21:25