jeudi 26 mars 2020

Check the value of variables in the files using if in Bash

I am trying to check the values of my variables are exist in the file or not using if condition in Bash. I tried is as follows, but for all the values I am getting value false.

a=-127.5256
b=24.5632

file=test.txt
-54.2565   58.9685
-127.2568  12.5890
-127.5256  24.5632
-78.9865   35.2366

I tried as follow but not working in my case:

if grep -Fxq "($a $b | bc)" $file; then
  echo True
else
  echo False

Is there any other way to perform the above job?

Thank you

Aucun commentaire:

Enregistrer un commentaire