Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


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

Rep: Reputation: 15
variables in bash


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

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

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

Original Poster
Rep: Reputation: 15

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, 11:01 AM   #4
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 17.3+18.3+19.0, MX-17
Posts: 4,198

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

more here

and a whole lot more here

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

Rep: Reputation: 45
Re: variables in bash

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, 07:45 AM   #6
LQ Newbie
Registered: Jul 2004
Distribution: Fedora
Posts: 25

Original Poster
Rep: Reputation: 15

That was it.
Old 09-22-2004, 06:29 PM   #7
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?


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 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 01:35 PM
sed with bash variables MurrayL Linux - Software 2 03-21-2005 09:13 AM
bash variables pfaendtner Linux - Newbie 4 11-23-2004 02:00 PM
Variables in bash tcaptain Programming 1 03-03-2003 03:07 PM
Bash variables pk21 Programming 2 01-09-2003 04:31 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:39 PM.

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