[] 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) ?
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.