Bash scripting "skip to"?
I grew up with ancient Commodore64 BASIC and really miss the GOTO command. Is there anything similar in BASH?
For instance, in a bash script, is there a way to tell it to: Code:
if condition X exists And incidentally, is there a more appropriate Forum for non-bug-report questions about BASH and other programs typically included in major Linux distributions? Most of the questions in "Linux - Software" seem a bit heavier than what I've been asking about... |
I'm not a programmer, but from what I've read, GOTO's are generally considered poor programming these days, and should be avoided whenever possible.
A better option, as I understand it, is to set up shell functions that you can import into the 'if' loops as needed. linuxcommand.org has an easy-to-understand explanation of them here and here. As for bash-related questions, I've generally gotten the best advice simply from the general linux forum. There's also the programming forum, which I guess might be better for advanced scripting questions. The forums all have clear descriptions listed, so simply choose the one that sounds like it best matches your question. If you're wrong, the moderators will simply move it to where it should be. |
I think the 'case' construct is what you need. In the use of case, you test for a condition, then code the action to take if that condition exists.
|
Quote:
|
I remember having this conversation before…
|
All times are GMT -5. The time now is 12:58 AM. |