0

I am writing a bash script and i get an error when i try to subtracts 2 variables. I tried many ways of declaring the subtraction as a single variable, but i am constantly getting errors. What's the right way to declare the variable? Thanks in advance.

if [ ${$packets1 - $packets2} -gt 30 ]
melpomene
  • 84,125
  • 8
  • 85
  • 148
Chris Tsiakoulas
  • 186
  • 5
  • 12

1 Answers1

0

Here you have a working solution for Bash :

packets1=300
packets2=176

if [ $(( packets1 - packets2 )) -gt 30 ]
then
    echo "This is true!"
fi

Regards!

Matias Barrios
  • 4,674
  • 3
  • 22
  • 49