LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Setting variables from a template (http://www.linuxquestions.org/questions/linux-newbie-8/setting-variables-from-a-template-828029/)

Feynman 08-23-2010 12:38 PM

Setting variables from a template
 
Is there a way I can write a file that contains the text which assigns variables, e.g.
string="hello world"
in a file say, variables.txt and have a shell script assign those variables locally e.g.

#!bin/bash
command_that_saves_variables_locally variables.txt
echo $string

and when I run the script I would get an output of
"hello world"

tuxtutorials 08-23-2010 12:53 PM

Have you tried:

Code:

. variables.txt
This should work too:

Code:

source variables.txt

Feynman 08-23-2010 01:08 PM

That worked great! Wow--that sure is simple in bash!


All times are GMT -5. The time now is 09:03 AM.