I would suggest a different approach. Your variables file is very similar to an assignment statement in shell syntax. The only problem is the whitespace around the assignment operator (you can find more details on that here). First, you could use a sed
command like the one below to fix the whitespace:
$ cat vars.txt
variable1 = 25
variable2 = 36
$ sed -i 's/ = /=/' vars.txt
$ cat vars.txt
variable1=25
variable2=36
Once you have done this, just source
the file to set all the variables as you need:
#!/bin/bash
source vars.txt
echo "Variable 1: $variable1, Variable 2: $variable2"
Which would give you the output:
Variable 1: 25, Variable 2: 36
As roaima notes in the comments, there is a security problem involved with this approach. When you source
your file, you're essentially running it as a shell script (Executing a script vs Sourcing a script is explained here). This means that you have to trust the contents of that file. If a malicious user or process is able to edit the file, you could end up executing arbitrary commands.
Also as roaima notes, quoting would be required if the values for the variables contain special characters. This answer was written specifically for the data set in the question, which only has numeric values for the variables. It cannot be easily extended for other types of values.