LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 08-23-2010, 12:38 PM   #1
Feynman
Member
 
Registered: Aug 2010
Distribution: Gentoo
Posts: 62

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.

#!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"
 
Old 08-23-2010, 12:53 PM   #2
tuxtutorials
Member
 
Registered: Dec 2008
Location: New York
Distribution: RedHat, Solaris
Posts: 68

Rep: Reputation: 16
Have you tried:

Code:
. variables.txt
This should work too:

Code:
source variables.txt
 
Old 08-23-2010, 01:08 PM   #3
Feynman
Member
 
Registered: Aug 2010
Distribution: Gentoo
Posts: 62

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


Reply

Tags
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


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

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