Anand K Nair
Anand K Nair

Reputation: 597

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?

Upvotes: 5

Views: 1612

Answers (1)

VGE
VGE

Reputation: 4191

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" ]]

Upvotes: 8

Related Questions