You are not logged in.
I want to source some file in bash script first,then to remove it and source another file with same variables but different values.
I know how to source file,but how to remove it, after variables are read?
Last edited by na12 (2011-01-13 10:09:22)
Offline
Just source the second file. The variables will overwrite those of the first if they are the same name.
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
Offline
If you want to be extra careful and there aren't too many variables, you can (should?) unset them before sourcing the second file:
unset var1 var2 var3 varA varB varC
source file2
This way, if file2 (for whatever reason) is missing any of the variables, it won't "inherit" the value from the previous file.
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
No,if one variable is missing from file2 it needs to be replaced with variable from file1.
Offline
No,if one variable is missing from file2 it needs to be replaced with variable from file1.
Fair enough... I guess you don't want to remove the first sourced file then?
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
Yes,but I thought it would be a conflict between these two files.
Offline