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

85 lines
1.7 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>If 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>If command</h2>
<p>The syntax of the <strong>if</strong> command is</p>
<p><strong>if</strong> <em>list1</em></p>
<p><strong>then</strong> <em>list2</em></p>
<p><strong>[</strong> <strong>elif</strong> <em>list3</em></p>
<p><strong>then</strong> <em>list4</em> <strong>]</strong> ...</p>
<p><strong>[</strong> <strong>else</strong> <em>list5</em> <strong>
]</strong></p>
<p><strong>fi</strong></p>
<p>First, <strong>qsh</strong> runs <em>list1</em> and if its exit
status is zero then <strong>qsh</strong> runs <em>list2</em>.
Otherwise, each elif <em>list3</em> is run and if its exit status
is zero then <strong>qsh</strong> runs <em>list4</em>. Otherwise,
<strong>qsh</strong> runs <em>list5</em>.</p>
<p><strong>Examples</strong></p>
<ol>
<li>An if-then-fi command.
<pre>
x=4
y=9
if test $x -lt $y
then
echo $x is less than $y
fi
</pre>
</li>
<li>An if-then-else-fi command.
<pre>
x=10
y=9
if test $x -lt $y
then
echo echo $x is less than $y
else
echo echo $x is greater than or equal to $y
fi
</pre>
</li>
<li>An if-then-elif-else-fi command.
<pre>
x=4
y=4
if test $x -lt $y
then
echo echo $x is less than $y
elif test $x -eq $y
then
echo $x is equal to $y
else
echo $x is greater than or equal to $y
fi
</pre>
</li>
</ol>
</body>
</html>