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

46 lines
1.2 KiB
HTML

<!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>Conditional 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>Conditional command</h2>
<p>The syntax of the <strong>[[...]]</strong> command is</p>
<p><strong>[[</strong> <em>expression</em> <strong>]]</strong></p>
<p>It returns a status of 0 or 1 depending on the evaluation of the
conditional expression <em>expression</em>. The format of a conditional
expression is the same as the expressions evaluated by the
<a href="test.htm">test</a> utility.
<strong>qsh</strong> performs tilde expansion, parameter expansion, arithmetic
expansion, command substitution, and quote removal on <em>expression</em>
before it is evaluated.
</p>
<p><strong>Examples</strong></p>
<ol>
<li>A conditional command that uses a command substitution.
<pre>
if [[ $(grep -c apple fruits.txt) -eq 0 ]]
then
echo There are no apples in fruit.txt
fi
</pre>
</li>
</ol>
</body>
</html>