LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 06: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, 06: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, 06:52 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
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, 06:54 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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


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


All times are GMT -5. The time now is 03:24 PM.

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