Read variables and their values from file

Hi,

I want to read the variables and the values from the txt file and compare these values with the ones computed by script.
for ex:
say var.txt contains the variable names and their values:
one 1
two 2
three 3

The value of variables "one" "two" and "three" will be computed in the script also. i want to compare the values read from var.txt and values computed in the script and check if thy are equal.

please help me.

Bhushana:

send me the sample values computed in the script

Hi,

Basically, I have values in a file as expected_output. These values are the sizes of the diff sections of the elf file.

And if the application is build with a particular option then i expect there should not be any changes to the sizes of some sections.

so i want to compare the expected output values with one i get after rebuilding the application.

I have got the solution:
But I wonder if there is any option which compares two hex values ( as readelf produces hex numbers but with no 0x prefix).
I have used "let "sec_size_hex=0x$sec_size" before doing the comparison.

something like?

one=1
two=2
three=5
 
while read var val
do
 if [ "$(eval echo \$$var)" -eq "$val" ]; then
  echo equal
 else
  echo not equal
 fi
done < var.txt

o/p:

equal
equal
not equal