LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Variable with bash (https://www.linuxquestions.org/questions/programming-9/variable-with-bash-168948/)

pinkysioux 04-11-2004 09:25 PM

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

pinkysioux 04-11-2004 09:27 PM

Excuse me notice that in my script,
I didn't forgot the " as I did in my thread..

pinkysioux 04-11-2004 09:47 PM

OK,

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

Sorry for being so silly

hanzerik 04-12-2004 12:16 PM

#!/bin/bash

var = "Arrrggghhhhhhh"
d=$( date )
echo $var
echo $d

pinkysioux 04-12-2004 04:24 PM

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.

7ux_spirit 04-12-2004 05:12 PM

"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.

hanzerik 04-15-2004 09:46 PM

Yea I messed up transcribing it.


All times are GMT -5. The time now is 01:20 PM.