LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-13-2004, 06:24 AM   #1
haddad
LQ Newbie
 
Registered: Jul 2004
Distribution: Fedora
Posts: 25

Rep: Reputation: 15
variables in bash


Hi

I have seen people assigning values to variables in the bash shell in the following syntax

somevar = "Some String"

However when I try this, I get an error "somevar: command not found"

Can someone shed some light on this for me plz

I am using the Bash shell in fedora core 2

Thanks
 
Old 08-13-2004, 06:27 AM   #2
whansard
Senior Member
 
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,304

Rep: Reputation: 65
export somevar="whatever"
 
Old 08-13-2004, 06:35 AM   #3
haddad
LQ Newbie
 
Registered: Jul 2004
Distribution: Fedora
Posts: 25

Original Poster
Rep: Reputation: 15
Hi,

That is what I am using, however I am still wondering why it shouldnt work when I see it in many books etc, and if I want to write a simple shell script that syntax above might not be suitable
 
Old 08-13-2004, 10:01 AM   #4
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
You'll find some information here:

http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html

more here

http://theory.uwinnipeg.ca/UNIXhelp/

and a whole lot more here

http://www.tldp.org/guides.html#abs

Have fun
 
Old 08-13-2004, 12:48 PM   #5
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
Re: variables in bash

Quote:
Originally posted by haddad
somevar = "Some String"
It could be your use of spaces. If you have "somevar[space]=", Bash will read "somevar" as a command. "somevar=" changes Bash's interpretation of the string.
 
Old 08-16-2004, 06:45 AM   #6
haddad
LQ Newbie
 
Registered: Jul 2004
Distribution: Fedora
Posts: 25

Original Poster
Rep: Reputation: 15
Thanks

That was it.
 
Old 09-22-2004, 05:29 PM   #7
Setheck
LQ Newbie
 
Registered: Jul 2004
Location: Seattle
Posts: 25

Rep: Reputation: 15
i'm having kindof the same problem.
except I need to assign $RULE_PATH to a directory...
also i want this variable assigned when the computer boots.
any help?
Thanks
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
(bash) how to list all variables? Duudson Programming 11 03-24-2005 12:35 PM
sed with bash variables MurrayL Linux - Software 2 03-21-2005 08:13 AM
bash variables pfaendtner Linux - Newbie 4 11-23-2004 01:00 PM
Variables in bash tcaptain Programming 1 03-03-2003 02:07 PM
Bash variables pk21 Programming 2 01-09-2003 03:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:59 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