LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 04-08-2009, 05:42 AM   #1
ssuhaib
LQ Newbie
 
Registered: Feb 2009
Posts: 9

Rep: Reputation: 1
Post Unable to set environmental variable


Hi,

When I type set varaible=somevalue ; export varable and then when I say echo $variable then nothing displays. How to set the variable or I am I doing anything wrong here?

The OS is RedHat 4.0 and shel is bash.

Thanks in advance
 
Old 04-08-2009, 05:46 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Check the syntax
Code:
$ MY_VAR=something; export MY_VAR
$ echo $MY_VAR
something
Be sure to avoid blank spaces around the equal sign. Also take in mind that the environment variable is assigned for the current shell session only. If you open a new shell, the newly assigned variable is not available. To make environment variables available every time you open a new shell session, put the assignment statement in $HOME/.bashrc.
 
Old 04-08-2009, 05:47 AM   #3
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
Quote:
Originally Posted by ssuhaib View Post
Hi,

When I type set varaible=somevalue ; export varable and then when I say echo $variable then nothing displays. How to set the variable or I am I doing anything wrong here?

The OS is RedHat 4.0 and shel is bash.

Thanks in advance
Well, if your typing is as inconsistent as above (3 different spellings of variable) then it's probably no wonder. (sorry, couldn't resist!)


BTW, on bash, there's no need to separate the export. you can also do

Code:
export MY_VAR="wibble"

Last edited by GazL; 04-08-2009 at 05:51 AM.
 
  


Reply



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
Help Me Set Environmental Variable In Nctuns 4.0 kathiravan Linux - Software 3 10-16-2008 10:32 AM
environmental variable myfoot Fedora 1 01-31-2008 05:36 PM
linux environmental variable surender Linux - General 2 05-07-2007 07:54 AM
how PKG_CONFIG_PATH environmental variable set these package hitlar Linux - Software 1 06-20-2006 10:46 PM
Setting an environmental variable maevious Linux - Newbie 6 11-24-2005 04:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:36 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration