Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-23-2010, 12:38 PM   #1
Registered: Aug 2010
Distribution: XUbuntu
Posts: 71

Rep: Reputation: 15
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.

command_that_saves_variables_locally variables.txt
echo $string

and when I run the script I would get an output of
"hello world"
Old 08-23-2010, 12:53 PM   #2
Registered: Dec 2008
Location: New York
Distribution: RedHat, Solaris
Posts: 68

Rep: Reputation: 16
Have you tried:

. variables.txt
This should work too:

source variables.txt
Old 08-23-2010, 01:08 PM   #3
Registered: Aug 2010
Distribution: XUbuntu
Posts: 71

Original Poster
Rep: Reputation: 15
That worked great! Wow--that sure is simple in bash!


bash, parse, string, template, variable

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
from django.template import Template, gives output firedancer Linux - Newbie 0 11-30-2007 02:08 PM
Setting PATH and other variables durrantj Ubuntu 2 08-25-2005 07:44 PM
Template class with a template member... Nicholas Bishop Programming 3 02-21-2005 08:27 PM
setting environment variables jayjoh Linux - Newbie 9 07-12-2004 12:35 PM
Setting Shell variables tmoorman Linux - Software 6 11-19-2003 03:41 PM > Forums > Linux Forums > Linux - Newbie

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