0

I try to run this BASH script, and it says on line 4 that it is missing a bracket.

#!/bin/bash

#Given an integer value, write a script to check to see if it is between     10 and 20(inclusive)
if [$value -le 20] && [$value -ge 10]; then
        echo "$value in in range"
else
        echo " $value is out of range"
fi

I'm doing this via SSH on a Linux server.

1 Answers1

1

Try like this

You need to put spaces before and after brackets.

#!/bin/bash

#Given an integer value, write a script to check to see if it is between     10 and 20(inclusive)
if [ $value -le 20 ] && [ $value -ge 10 ]; then
        echo "$value in in range"
else
        echo " $value is out of range"
fi

Here is the explanation why we need to do that Why should there be a space after '[' and before ']' in Bash?

Community
  • 1
  • 1
Juned
  • 6,056
  • 7
  • 41
  • 91