📄 testbranch.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><HTML><HEAD><TITLE>Testing and Branching</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="Advanced Bash-Scripting Guide"HREF="index.html"><LINKREL="UP"TITLE="Loops and Branches"HREF="loops.html"><LINKREL="PREVIOUS"TITLE="Loop Control"HREF="loopcontrol.html"><LINKREL="NEXT"TITLE="Command Substitution"HREF="commandsub.html"><METAHTTP-EQUIV="Content-Style-Type"CONTENT="text/css"><LINKREL="stylesheet"HREF="common/kde-common.css"TYPE="text/css"><METAHTTP-EQUIV="Content-Type"CONTENT="text/html; charset=iso-8859-1"><METAHTTP-EQUIV="Content-Language"CONTENT="en"><LINKREL="stylesheet"HREF="common/kde-localised.css"TYPE="text/css"TITLE="KDE-English"><LINKREL="stylesheet"HREF="common/kde-default.css"TYPE="text/css"TITLE="KDE-Default"></HEAD><BODYCLASS="SECT1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#AA0000"VLINK="#AA0055"ALINK="#AA0000"STYLE="font-family: sans-serif;"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">Advanced Bash-Scripting Guide: An in-depth exploration of the art of shell scripting</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="loopcontrol.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 10. Loops and Branches</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="commandsub.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="TESTBRANCH"></A>10.4. Testing and Branching</H1><P>The <BCLASS="COMMAND">case</B> and <BCLASS="COMMAND">select</B> constructs are technically not loops, since they do not iterate the execution of a code block. Like loops, however, they direct program flow according to conditions at the top or bottom of the block.</P><DIVCLASS="VARIABLELIST"><P><B><ANAME="CASEESAC1"></A>Controlling program flow in a code block</B></P><DL><DT><BCLASS="COMMAND">case (in) / esac</B></DT><DD><P>The <BCLASS="COMMAND">case</B> construct is the shell scripting analog to <BCLASS="COMMAND">switch</B> in C/C++. It permits branching to one of a number of code blocks, depending on condition tests. It serves as a kind of shorthand for multiple <SPANCLASS="TOKEN">if/then/else</SPAN> statements and is an appropriate tool for creating menus.</P><P><P><BCLASS="COMMAND">case</B> "$<TTCLASS="REPLACEABLE"><I>variable</I></TT>" in <BR><BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -