0

I have an error on my code...

if [ $timestamp -gt $timestampuser1 && $timestamp -lt $timestampuser2 ] ; then       echo "$d"
fi

When I run it I get this error:

./data.sh: line 31: [: missing `]'

What is wrong with it??

Ryad Boubaker
  • 1,491
  • 11
  • 16
Pedro Martins
  • 125
  • 2
  • 9
  • 1
    If your shell is really bash (as you tagged the question) and not `/bin/sh`, consider `if (( timestamp > timestampuser1 && timestamp < timestampuser2 )); then ...`. You could also use `if [[ $timestamp -gt $timestampuser1 && $timestamp -lt $timestampuser2 ]]`, but if one's going to be using extended syntax, might as well use the more applicable extensions available. *Don't* use `-a` or `-o` in place of `&&` and `||` -- the current version of POSIX [explicitly marks them obsolescent](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html). – Charles Duffy Feb 21 '17 at 16:20
  • thanks for the help – Pedro Martins Feb 21 '17 at 16:23

0 Answers0