I am new to shell scripting. I am working on a project where the requirement is like one script file will set the variables and another script file has to get those variables and manipulate it. I am storing the variables from first script into a file and in second script file I am reading it.
In first script file, first.sh , I am doing like
echo "a=6" > test.dat
echo "b=7" >> test.dat
echo "c=8" >> test.dat
I use > for the first variable where it overwrites and for the next values it appends. So the file will have the latest values always.
Is there any better approach than this ?
In the second script file how can read and fill the appropriate values ?
You can load this variables from the script using
source:or just
Example:
If you have a script/program that generates these variables, you can also use
eval.Example: