IMPORT VARIABLE(S) AND FUNCTION(S) FROM FILE
September 14th, 2006 durian Posted in Common, source | Hits: 40024 | 4 Comments »
If you have a lot of variables set in a configuration file and you need to access all those variables quickly, you can try to use
source filename
For example, you have a configuration file named /etc/vars.conf with the following content:
VAR1=hkong
VAR2=is
VAR3=leaving
function test1 {
echo $VAR3 $VAR2 $VAR1
}
You can then invoke
source /etc/vars.conf
Then the variables and function will be accessible as depicted in the following example
echo $VAR1 $VAR2 $VAR3
hkong is leaving
test1
leaving is hkong
This command is most commonly used by startup scripts to import variables
and functions
September 14th, 2006 at 5:59 pm
(: Ya I am leaving soon.
September 14th, 2006 at 8:11 pm
Good Job.3 months ago, it is still an idea, but just 3 months, u have realize your dream..ç»§ç»åŠªåŠ›ï¼
January 18th, 2011 at 5:22 am
Advantageously, this submit is definitely the greatest on this invaluable topic. I fit in along with your explanations and can eagerly look forward to your forthcoming updates. Simply saying thanks won’t just be enough, for the great readability in your documentation. I will instantly grab your rss feed to remain abreast of any updates. Fabulous work and a variety of success in what you are promoting dealings!
July 6th, 2011 at 2:38 am
Thanks for posting this. It saved me hours of searching!