line 5: [: -gt: unary operator expected

Hello all, :confused:
I am not getting this error.
Pls help me.

./construct_operon.sh: line 5: [: -gt: unary operator expected
#!/bin/bash
# Construct Operons using gene pairs.
rm -rf operons_result
lines=`awk 'END {print NR}' ecoli_operons`
while [ $lines -gt 0 ];
do
    head -1 ecoli_operons | awk '{print $1"\n"$2}' > pattern
    grep -f pattern ecoli_operons | awk '{print $1"\n"$2}' > temp
    pat_count=`grep -f pattern -v temp | awk 'END {print NR}'`
    while [ $pat_count -gt 0 ];
    do
        cat temp >> pattern
        grep -f pattern ecoli_operons | awk '{print $1"\n"$2}' > temp
        pat_count=`grep -f pattern -v temp | awk 'END {print NR}'`
    done
    grep -f pattern ecoli_operons | awk '{print $1"\n"$2}' | sort -u | awk '{printf $0"\t"} END {printf"\n"}' >> operons_result
    grep -f pattern -v ecoli_operons > temp1
    mv temp1 ecoli_operons
    echo $lines
    lines=`awk 'END {print NR}' ecoli_operons`
done
rm -rf temp
rm -rf pattern

Thanks in advance.

Do the correction below:-

while [[ $lines -gt 0 ]]
do
commands
done

[] shouldn't be neccessary if the file ecoli_operons exists and is readable as the Awk always returns a number. It should even work on Solaris!

I would be more inclined to use "wc -l < ecoli_eperons", or "grep -c . ecoli_operons", but as I test the code given, it works fine as ilong as the file is readable.

As other posters imply, what is the response to typing this command at the same place where you might execute the script? The error message implies that the response is not a number.

Knowing the Operating System and version would help.
Clutching at straws and if the above command does not give an error message.
1) The environment variable $LINES is reserved in all modern shells. Though I have no factual reason to suggest this, you could try another name for the variable $lines.
2) A script edited on a MSDOS and ported to unix without proper text file conversion could misbehave like this.
3) The trailing semi-colon on "while [ $lines -gt 0 ];" is surplus.
4) How big is the file? Is $lines a very large number (> 2x1024x1024x1024) ?

ahmad.diab's solution is working.
"awk 'END {print NR}' ecoli_operons" is working.
file size is > 10x1024.
Thanks to all.

As per admax request kindly see below why I did use [[ ]] in bash loops

[[ ]]
test.
Test expression between [[ ]]. This is a shell keyword

The [[ ]] construct is the more versatile Bash version of [ ]. This is the extended test command, adopted from
ksh88.
No filename expansion or word splitting takes place between [[ and ]], but there is parameter expansion
and command substitution.
file=/etc/passwd
if [[ -e $file ]]
then
echo "Password file exists."
fi
Using the [[ ... ]] test construct, rather than [ ... ] can prevent many logic errors in scripts. For example,
the &&, ||, <, and > operators work within a [[ ]] test, despite giving an error within a [ ] construct.

BR