LinuxQuestions.org
Visit Jeremy's Blog.
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, 07: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, 08: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, 08: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, 08: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, 11:14 AM   #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 05:52 AM
Scripting question mithereal Linux - General 2 09-21-2005 02:02 AM
Scripting question msandford Linux - Newbie 4 09-05-2005 10:23 AM
scripting question gearoid Programming 3 05-26-2004 02:43 PM
Scripting question glock19 Linux - Software 2 09-05-2003 12:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:41 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
Open Source Consulting | Domain Registration