Bash Loops
Hey guys, i've been searching all over the internet to try and figure this one out, and I stumbled across this forum. It seemed like a good place to get some help ;)
I'm new to Linux and Bash, and i'm trying to write my first proper script at the moment. However i'm stuck trying to create a working loop for a case statement. It goes something like this: Code:
echo "Selection 1" I tried using something like: Code:
loop=0 Is there any simple way to achieve what I'm wanting to do? Any help is much appreciated. :) |
use functions, for example:
Code:
function <name> { Hope this helps |
Quote:
I just tried doing that but I got an unexpected end of file error on the line where I closed the function bracket (after 'esac') |
Actually i was originally thinking of putting the menu bit in a function like this:
Code:
function mainmenu { |
Yeah I don't think that'd work, as the entire case statement needs to run again. Thanks anyway ;)
|
Basically i've been trying to write a loop that lets me go back to the start of the program so the user can input another selection once their first selection has been displayed.
That's a case for "select" me thinks: Code:
|
while [ $x != "quit" ]
do . . . done Have a look on tldp.org for the abs (says advanced, but isn't really) Edit: man, I gotta learn to type faster ... As usual, always more than one answer - at least we both agree on "quit" ;) |
Thanks for that. I'll give it a go now.
|
Hmm nope can't get any of it to work. I just end up getting "unexpected end of file" errors :S
Might have to spend a bit of time looking at my code. |
All times are GMT -5. The time now is 04:27 AM. |