LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   bash question (https://www.linuxquestions.org/questions/linux-general-1/bash-question-561033/)

slimm609 06-11-2007 08:13 PM

bash question
 
Does anyone know what the difference between the following is?

TEST="this test"

echo $TEST
response: this test

echo ${TEST}
resopnse: this test

so I was wondering what the {} in the second echo statement does different then the first one



Thanks

pixellany 06-11-2007 08:49 PM

the { } is used for what is called "brace expansion". To get an idea what it does, do these:

echo {a,z}

echo {a..z}


In your example, the braces do nothing.

slimm609 06-11-2007 09:09 PM

that does not work for variables

i think it is used for an array

like
${TEST[2]}
which would out put the 3rd entry in the array


thanks

Tinkster 06-12-2007 04:47 AM

Copy & paste that (including the empty line) into
an xterm or similar :}
Code:

man bash
/  Parameter Expansion



Cheers,
Tink


All times are GMT -5. The time now is 05:44 PM.