LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Make a bash script loop from start (https://www.linuxquestions.org/questions/linux-newbie-8/make-a-bash-script-loop-from-start-666263/)

evansd321 08-29-2008 06:00 AM

Make a bash script loop from start
 
Hi all, I am very new to Linux and I have a question.

How can I get a bash script to keep looping from the start "without" using any goto commands :)

for example my script has the following commands . . .

w
sleep 1
clear

. . . but then I want it to start all over again from the "w" command and keep doing so untill stop it.

Any assistance would be a real help to me :)

Thanks

Darren

arizonagroovejet 08-29-2008 06:16 AM

Make the last line of the script

exec $0

colucix 08-29-2008 06:20 AM

Hi and welcome to LQ! How do you suppose to stop the process? You can try an infinite loop like the following and stop it using Ctrl-C
Code:

while true
do
  your commands here
done


GazL 08-29-2008 06:20 AM

Code:

#!/bin/bash
while true
do
  echo "Some commands to loop endlessly go here."
done

edit: damn, beaten to it. :)

evansd321 08-29-2008 06:32 AM

Working perfect!!!
 
Thanks for your help everyone, it's working perfect now!! :)

mrrangerman 08-29-2008 11:37 AM

Sounds like homework to me???


All times are GMT -5. The time now is 02:55 AM.