Bashing on your door again!!
I am trying to get a test piece of code working, it is based around a simple menu system. I can not get a while loop to work within another while loop. Can you answer my question? And if you find the answer to that one can you tell me how to use the || operator so I can catch both uppercase and lowercase for "Y" and "y" in the menu.
Thank you in advance, here's the code not very exciting, just a tester for the while loop: Code:
#!/bin/bash |
You're confusing "-eq" that means numerically equal with "=" that check string equality, so
Code:
while [ "$again" -eq "y" ]; do Code:
while [ "$again" = "y" ]; do Code:
while [ "$again" = "y" -o "$again" = "Y" ]; do Don't confuse "||" from "-o", the former is to use between shell commands while the latter is for combining test (aka "[") clauses. |
I would usually use "==" for the while loop. Including OR it would be:
Code:
while [ "$again" == "y" ] || [ "$again" == "Y" ]; do Code:
Q|q) |
This site as got the most helpful people on the planet, I swear!! Thanks guys!
|
All times are GMT -5. The time now is 04:54 AM. |