LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Looping a script (https://www.linuxquestions.org/questions/linux-newbie-8/looping-a-script-524160/)

Keentolearn 01-30-2007 03:12 PM

Looping a script
 
Is there a way that the user can re use the script with out opening it?

using and if statement for example

echo "Would you like to run this script again Y/N"
read answer
if answer="Y"
then
.....
else
exit
fi

Regards.

raskin 01-30-2007 03:29 PM

Read man bash, really.

REPEAT=Y
while [ "REPEAT" = Y ]; do
...
echo "Would you like to run this script again Y/N";
read REPEAT;
done;

Keentolearn 01-30-2007 03:34 PM

Thank you very much.

bogzab 01-30-2007 03:47 PM

Actually man bash is pretty impenetrable. You might prefer to start with one of the many bash tutorials that are around the web. One is http://www-128.ibm.com/developerwork...ry/l-bash.html

Bogus

raskin 01-30-2007 03:54 PM

Well, why do you undermine self-confidence of someone who hasn't yet tried? Man bash is not impenetrable - I read it having knowledge level no higher than Keentolearn's one, I guess. Really both man bash and info bash are rather compressed, and are close derivatives of POSIX standard for shell. But they can be read - at least when you believe in yourself.


All times are GMT -5. The time now is 09:29 AM.