ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahz_5.4.0.1/casecmd.htm

58 lines
1.4 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8">
<title>Case command</title>
<LINK rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</HEAD>
<body bgcolor="#FFFFFF">
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h2>Case command</h2>
<p>The syntax of the <strong>case</strong> command is</p>
<p><strong>case</strong> <em>word</em> <strong>in</strong></p>
<p><em>pattern1</em> ) <em>list1</em> ;;</p>
<p><em>pattern2</em> | <em>pattern3</em> ) <em>list2</em> ;;</p>
<p>...</p>
<p><strong>esac</strong></p>
<p><strong>qsh</strong> expands each <em>pattern</em> in turn and
sees if it matches the expansion of <em>word</em>. When there is a
match, <strong>qsh</strong> runs the corresponding <em>list</em>.
After the first match, no more patterns are expanded. See <a href=
"pattern.htm">"Shell Patterns"</a> for more details on
patterns.</p>
<p><strong>Examples</strong></p>
<ol>
<li>A case command for processing command line options.
<pre>
while getopts ap:t: c ; do
case $c in
a) aflag=1;;
p) pflag=1
path=$OPTARG;;
t) time=$OPTARG;;
*) print -u2 "Invalid option"
exit 1;;
esac
done
</pre>
</li>
</ol>
</body>
</html>