LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 08-29-2008, 07:00 AM   #1
evansd321
LQ Newbie
 
Registered: Aug 2008
Posts: 24

Rep: Reputation: 0
Cool 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
 
Old 08-29-2008, 07:16 AM   #2
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: SLED, openSUSE
Posts: 1,032

Rep: Reputation: 174Reputation: 174
Make the last line of the script

exec $0
 
Old 08-29-2008, 07:20 AM   #3
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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
 
Old 08-29-2008, 07:20 AM   #4
GazL
Senior Member
 
Registered: May 2008
Posts: 3,503

Rep: Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026Reputation: 1026
Code:
#!/bin/bash
while true
do
  echo "Some commands to loop endlessly go here."
done
edit: damn, beaten to it.
 
Old 08-29-2008, 07:32 AM   #5
evansd321
LQ Newbie
 
Registered: Aug 2008
Posts: 24

Original Poster
Rep: Reputation: 0
Thumbs up Working perfect!!!

Thanks for your help everyone, it's working perfect now!!
 
Old 08-29-2008, 12:37 PM   #6
mrrangerman
Member
 
Registered: Oct 2007
Location: MI
Distribution: Debian Slackware
Posts: 528

Rep: Reputation: 50
Sounds like homework to me???
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to loop over text file lines within bash script for loop? johnpaulodonnell Linux - Newbie 8 04-05-2011 10:18 AM
How to make a bash script to start & end apache and mysql ? rova Programming 2 03-01-2008 08:27 PM
bash script loop bong.mau Programming 6 09-14-2005 08:38 PM
bash script for loop drisay Programming 5 12-25-2004 01:32 AM
bash script - for loop question rignes Programming 3 10-06-2004 12:16 AM


All times are GMT -5. The time now is 01:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration