LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-07-2005, 05:44 PM   #1
sabliny
LQ Newbie
 
Registered: Oct 2005
Posts: 7

Rep: Reputation: 0
can you use goto in bash script


I am using Red Hat linux.

Can you use 'goto' in a bash script to jump to a label based on an if condition.


Thanks,

sabliny
 
Old 10-07-2005, 05:50 PM   #2
nixcraft
Member
 
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379

Rep: Reputation: 30
Noop, use if command.

if [ condition ]; then
...
else
...
fi
 
Old 10-07-2005, 05:52 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
goto's are a hideously awful way to program, you should use a function or a similar construct instead: http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-8.html
 
Old 10-07-2005, 05:54 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
It is practically impossible to teach good programming style to
students that have had prior exposure to BASIC: as potential
programmers they are mentally mutilated beyond hope of
regeneration.
-- Dijkstra


Cheers,
Tink
 
  


Reply



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
BASH goto dkrysak Programming 35 03-21-2013 10:22 AM
goto/label command for scripting in bash shell terry.trent Linux - Software 3 07-09-2010 10:15 AM
goto in linux shell script sabliny LinuxQuestions.org Member Intro 1 10-13-2005 03:00 PM
how to create a script that can goto different dir and also to run prompts ann124 Programming 5 11-29-2004 12:48 PM
GOTO function in bash? sobchak Programming 1 07-22-2002 05:10 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:24 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