LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-11-2004, 08:25 PM   #1
pinkysioux
LQ Newbie
 
Registered: Apr 2004
Posts: 5

Rep: Reputation: 0
Variable with bash


Hi,

I'm goona look pretty silly
but how do you initialize a variable with bash ?

Just for instance a string ...

I'm trying this and it's not working:

#!/bin/bash

set var = "Arrrggghhhhhhh"
set d=`date`
echo "$var
echo $d




Why is itnot working ??


Thanks for your help


PInkysioux
 
Old 04-11-2004, 08:27 PM   #2
pinkysioux
LQ Newbie
 
Registered: Apr 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Excuse me notice that in my script,
I didn't forgot the " as I did in my thread..
 
Old 04-11-2004, 08:47 PM   #3
pinkysioux
LQ Newbie
 
Registered: Apr 2004
Posts: 5

Original Poster
Rep: Reputation: 0
OK,

I'm gonna go to bed....
So there's no "set" to put on.

Sorry for being so silly
 
Old 04-12-2004, 11:16 AM   #4
hanzerik
Member
 
Registered: Jan 2002
Location: Cheyenne Wyoming
Distribution: Debian/Raspbian/Mint
Posts: 717

Rep: Reputation: 32
#!/bin/bash

var = "Arrrggghhhhhhh"
d=$( date )
echo $var
echo $d
 
Old 04-12-2004, 03:24 PM   #5
pinkysioux
LQ Newbie
 
Registered: Apr 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Maybe it's not the same for you,

but on my system, I found I must not put space between the name of the variable, the sigle "=" and the value......

I find it surprising, do you think it's because I'm used of script in sh ??

Thanks for your help.
 
Old 04-12-2004, 04:12 PM   #6
7ux_spirit
LQ Newbie
 
Registered: Apr 2004
Distribution: Redhat 8.0
Posts: 21

Rep: Reputation: 15
"but on my system, I found I must not put space between the name of the variable, the sigle "=" and the value......"

yep spaces do matters in bash scripts.

When bash sees a statement like
var = "Arrrggghhhhhhh"
it sees 'var' as the command and the rest 2 its arguments.
 
Old 04-15-2004, 08:46 PM   #7
hanzerik
Member
 
Registered: Jan 2002
Location: Cheyenne Wyoming
Distribution: Debian/Raspbian/Mint
Posts: 717

Rep: Reputation: 32
Yea I messed up transcribing it.
 
  


Reply


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
Bash, using variable in sed fur Programming 3 11-12-2005 07:41 AM
bash, how to get variable name from variable Duudson Programming 6 01-06-2005 04:38 PM
how to escape variable in bash??? rabbate Linux - General 4 03-17-2004 08:04 PM
bash - how to take input as a variable? trees Linux - General 1 02-19-2004 04:09 PM
BASH variable export Barbarian Programming 2 11-27-2001 08:37 PM


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