Reputation: 137
It's there a simple way to write multiple variables into a file and later to read them?
For example to write the next variables into a file:
test=1
b=3
a=earth
echo "test=1" > variables.prop
echo "b=3" >> variables.prop
echo "a=earth" >> variables.prop
And somehow to return the value of specified variable and use it. Like
*command to import the variable "test" from the text file*
echo $test
*command to import the variable "b" from the text file*
echo $b
and the expected output for "test" should be "1" and for "b" to be "3".
Upvotes: 0
Views: 1562
Reputation: 361565
Create variables.prop
exactly as you're doing, then use the .
command (AKA source
) to read it in.
. variables.prop
echo "$test"
echo "$b"
Upvotes: 1