pretty simple script but I am having issues with it. It will not compare the 2 variables, is this due to floating points or? I tried to use the | bc but still not working...
#!/bin/bash
x=$(curl -o /dev/null -s -w %{time_total}\\n http://www.google.com) | bc
y=.5 | bc
if [[ $x -gt $y ]]; then
echo “fast”
else
echo “not as fast”
fi
updated code to: #!/bin/bash
x=$(curl -o /dev/null -s -w %{time_total}\\n http://www.google.com)
y=.5
if (( $(bc <<<'$x > $y') )); then
echo “fast”
else
echo “not as fast”
fi
Receiving errors: (standard_in) 1: illegal character: $ (standard_in) 1: illegal character: $ “not as fast”