LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 12-14-2007, 09:35 AM   #1
coldbeerz
LQ Newbie
 
Registered: Nov 2007
Location: PA
Posts: 7

Rep: Reputation: 0
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/

Last edited by coldbeerz; 12-14-2007 at 09:40 AM.
 
Old 12-14-2007, 09:42 AM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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.
 
Old 12-14-2007, 09:48 AM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

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


Reply

Tags
bash, export, shell, variable


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
useradd: cannot create directory /home/ amirzkria Red Hat 5 08-07-2014 09:11 AM
create a new user with a different home directory cccc Debian 6 08-06-2008 05:47 AM
how to create a new partition for current /home directory? parv Linux - Hardware 3 02-27-2007 09:21 AM
how to add environment variable to .bashrc file hasan Linux - General 7 10-03-2003 04:43 PM
how to add environment variable to .bashrc file? hasan Red Hat 1 10-03-2003 01:37 PM


All times are GMT -5. The time now is 12:47 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration