52 lines
1.5 KiB
HTML
52 lines
1.5 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>Command substitutions</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>Command substitutions</h2>
|
|
|
|
<p>Command substitution allows the output of a command to be
|
|
substituted in place of the command name itself. Command
|
|
substitution occurs when the command is enclosed as follows:</p>
|
|
|
|
<p>$(<em>command</em>)</p>
|
|
|
|
<p>or by using backquotes:</p>
|
|
|
|
<p>`<em>command</em>`</p>
|
|
|
|
<p>The backquoted version is provided for compatibility. Its use is
|
|
discouraged.</p>
|
|
|
|
<p>The shell expands the command substitution by running <em>
|
|
command</em> in a subshell environment and replacing the command
|
|
substitution with the standard output of the <em>command</em>,
|
|
removing sequences of one or more <newline>s at the end of
|
|
the substitution. Embedded <newline>s before the end of the
|
|
output are not removed; however, during field splitting, they may
|
|
be translated into <space>s, depending on the value of the
|
|
<strong>IFS</strong> variable and quoting that is in effect.</p>
|
|
|
|
<p><strong>Examples</strong></p>
|
|
|
|
<ol>
|
|
<li>Set the variable list to the output of the ls command:
|
|
<pre>
|
|
list=$(ls)
|
|
</pre>
|
|
</li>
|
|
|
|
</ol>
|
|
</body>
|
|
</html>
|