LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   create a variable in the .bashrc file in my home directory (https://www.linuxquestions.org/questions/linux-newbie-8/create-a-variable-in-the-bashrc-file-in-my-home-directory-606764/)

coldbeerz 12-14-2007 09:35 AM

create a variable in the .bashrc file in my home directory
 
I need to create a varaible ($DOC) in the .bashrc file in my home directory (/home/machinename/)as a shortcut to the files in /usr/share/doc
The variable should be called DOC

I am using Red Hat 3.0 workstation

I thought I had the correct command. I used vi editor on .bashrc
I inserted the command
path=$path:/usr/share/doc/

matthewg42 12-14-2007 09:42 AM

You need to export variable if they are to be used by processes other than the shell itself. Also, note that variable names are case sensitive - path is not the same as PATH.

For example:
Code:

myvar="something"
program_1
export myvar
program_2

Here program_1 cannot see myvar in the environment, but program_2 can.

You can do it all in one go like this:
Code:

export myvar="something"
Note that you will probably have to log out and back in again before variables which are set in your .bashrc are usable.

jschiwal 12-14-2007 09:48 AM

You could also create a symlink to /usr/share/doc:
For example:
ln -s /usr/share/doc ~/sysdocs


All times are GMT -5. The time now is 08:35 AM.