Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax error in conditional expression

I try:

        while [[ $c -le $n]]
        do
        now=$(date +"%T")
        echo "Tps at :- $now"
        @c=$c+1
        done

I got:

   syntax error in conditional expression

   syntax error near `do'

Can someone figure out what's wrong?

like image 392
Anand K Nair Avatar asked May 11 '12 10:05

Anand K Nair


1 Answers

You need a space before closing test expression

while [[ $c -le $n ]]

And surround your variable with "" to avoid some painful error :

while [[ "$c" -le "$n" ]]
like image 105
VGE Avatar answered Oct 16 '22 01:10

VGE