IMPORT VARIABLE(S) AND FUNCTION(S) FROM FILE
0 votos
September 14th, 2006 durian Posted in Common, source | Hits: 1888 |
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
Live Chat!









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..ç»§ç»åŠªåŠ›ï¼