LinuxQuestions.org
Help answer threads with 0 replies.
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 11-10-2004, 08:55 PM   #1
Darklight451
LQ Newbie
 
Registered: Sep 2004
Distribution: Fedora core 2
Posts: 13

Rep: Reputation: 0
Scripting Question


Is there a 'goto' command to goto a certain line in a bash script? I want a section of code to loop, any good ideas?
 
Old 11-10-2004, 09:02 PM   #2
m00t00
Member
 
Registered: Sep 2004
Distribution: Slackware 10, Gentoo
Posts: 292

Rep: Reputation: 30
stay FAR, FAR, away from goto. there are real loops in bash...
 
Old 11-10-2004, 09:11 PM   #3
Darklight451
LQ Newbie
 
Registered: Sep 2004
Distribution: Fedora core 2
Posts: 13

Original Poster
Rep: Reputation: 0
alright, can you point me in the right direction then?
 
Old 11-10-2004, 09:30 PM   #4
goofyheadedpunk
Member
 
Registered: Aug 2003
Distribution: Arch Linux
Posts: 140

Rep: Reputation: 15
Bash has while and for loops, perhaps more but those are the only two I can think of off the top of my head. You can read more about them in the Advanced Bash-Scripting Guide.

Also, bash supports sub-routines. Here's an example of a very simple one
Code:
usage()
{
        echo "Usage: $0 [directory]"
        exit 1;
}
which can be called like so
Code:
test -d "$1" || usage
 
Old 11-12-2004, 12:14 PM   #5
m00t00
Member
 
Registered: Sep 2004
Distribution: Slackware 10, Gentoo
Posts: 292

Rep: Reputation: 30
^^^^

what he said =P
 
  


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
scripting question... Basslord1124 Linux - Networking 2 11-09-2005 06:52 AM
Scripting question mithereal Linux - General 2 09-21-2005 03:02 AM
Scripting question msandford Linux - Newbie 4 09-05-2005 11:23 AM
scripting question gearoid Programming 3 05-26-2004 03:43 PM
Scripting question glock19 Linux - Software 2 09-05-2003 01:45 AM


All times are GMT -5. The time now is 02:01 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration