Review your favorite Linux distribution.
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, 06: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, 06:27 AM   #2
Senior Member
Registered: Dec 2002
Location: Mosquitoville
Distribution: RH 6.2, Gen2, Knoppix,arch, bodhi, studio, suse, mint
Posts: 3,185

Rep: Reputation: 52
export somevar="whatever"
Old 08-13-2004, 06: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, 10:01 AM   #4
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 42.1_64-KDE, Ubuntu 14.04, Mint 17.2
Posts: 3,916

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

more here

and a whole lot more here

Have fun
Old 08-13-2004, 12: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, 06:45 AM   #6
LQ Newbie
Registered: Jul 2004
Distribution: Fedora
Posts: 25

Original Poster
Rep: Reputation: 15

That was it.
Old 09-22-2004, 05:29 PM   #7
LQ Newbie
Registered: Jul 2004
Location: FLorida USA
Distribution: Slackware
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 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

All times are GMT -5. The time now is 11:31 AM.

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