PDA

View Full Version : [SOLVED] BASH: quick conditional statement problem



derelict888
February 12th, 2010, 07:41 PM
I've got a problem with a conditional statement in one of my while loops, bad syntax I'm sure;


while [ "$c" <= "$j" ] ; do

I want the statement to work like "while var c is less than or equal to var j, continue. This statement is getting passed to a host via SSH (if that might change how to write this out).

Thanks for any help, the rest of my code is fine since I've tested it, I've got just this conditional wrong.

m_duck
February 12th, 2010, 07:50 PM
I think where you have <= it should be -le:

while [ "%c" -le "$j" ]; do

Bash comparisons (http://tldp.org/LDP/abs/html/comparison-ops.html)

derelict888
February 12th, 2010, 07:53 PM
I think where you have <= it should be -le:

while [ "%c" -le "$j" ]; do

Bash comparisons (http://tldp.org/LDP/abs/html/comparison-ops.html)

Great that did it ty.