⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0022-0022.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Linux Complete Command Reference:User Commands:EarthWeb Inc.-</TITLE>

</HEAD>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311046 //-->

<!-- TITLE=Linux Complete Command Reference//-->

<!-- AUTHOR=Red Hat//-->

<!-- PUBLISHER=Macmillan Computer Publishing//-->

<!-- IMPRINT=Sams//-->

<!-- CHAPTER=01 //-->

<!-- PAGES=0001-0736 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->



<P><CENTER>

<a href="0020-0021.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0023-0024.html">Next</A></CENTER></P>







<A NAME="PAGENUM-22"><P>Page 22</P></A>





<P>The word that follows the redirection operator in the following descriptions is subjected to brace expansion, tilde

expansion, parameter expansion, command substitution, arithmetic expansion, quote removal, and pathname expansion. If it expands

to more than one word, bash reports an error.</P>

<P>Note that the order of redirections is significant. For example, the command:</P>



<!-- CODE SNIP //-->

<PRE>

ls &gt; dirlist 2&gt;&amp;1

</PRE>

<!-- END CODE SNIP //-->



<P>directs both standard output and standard error to the file

dirlist, while the command

</P>



<!-- CODE SNIP //-->

<PRE>

ls 2&gt;&amp;1 &gt; dirlist

</PRE>

<!-- END CODE SNIP //-->

</P>



<P>directs only the standard output to file

dirlist, because the standard error was duplicated as standard output before

the standard output was redirected to dirlist.

</P>



<P>

<b>REDIRECTING OUTPUT</b>

</P>



<P>Redirection of input causes the file whose name results from the expansion of word to be opened for reading on

file descriptor n, or the standard input (file descriptor

0) if n is not specified.</P>



<P>The general format for redirecting input is</P>



<!-- CODE SNIP //-->

<PRE>

[n]&lt;word

</PRE>

<!-- END CODE SNIP //-->



<P>

<b>REDIRECTING OUTPUT</b>

</P>



<P>Redirection of output causes the file whose name results from the expansion of word to be opened for writing on

file descriptor n, or the standard output (file descriptor

1) if n is not specified. If the file does not exist, it is created; if it

does exist it is truncated to zero size.</P>



<P>The general format for redirecting output is</P>



<!-- CODE SNIP //-->

<PRE>

[n]&gt;word

</PRE>

<!-- END CODE SNIP //-->



<P>If the redirection operator is &gt;|, then the value of the

-C option to the set built-in command is not tested, and file creation

is attempted. (See also the description of

noclobber under &quot;Shell Variables,&quot; earlier in this manual page.)</P>



<P>

<b>APPENDING REDIRECTED OUTPUT</b>

</P>



<P>Redirection of output in this fashion causes the file whose name results from the expansion of word to be opened

for appending on file descriptor n, or the standard output (file descriptor

1) if n is not specified. If the file does not exist, it

is created.</P>



<P>The general format for appending output is</P>



<!-- CODE SNIP //-->

<PRE>

[n]&gt;&gt;word

</PRE>

<!-- END CODE SNIP //-->



<P>

<b>REDIRECTING STANDARD OUTPUT AND STANDARD ERROR</b>

</P>



<P>bash allows both the standard output (file descriptor

1) and the standard error output (file descriptor

2) to be redirected to the file whose name is the expansion of word with this construct.</P>



<P>There are two formats for redirecting standard output and standard error:</P>



<!-- CODE SNIP //-->

<PRE>

&amp;&gt;word

</PRE>

<!-- END CODE SNIP //-->



<P>and</P>



<!-- CODE SNIP //-->

<PRE>

&gt;&amp;word

</PRE>

<!-- END CODE SNIP //-->



<P>Of the two forms, the first is preferred. This is semantically equivalent to</P>



<!-- CODE SNIP //-->

<PRE>

&gt;word 2&gt;&amp;1

</PRE>

<!-- END CODE SNIP //-->



<P>

<b>HERE-DOCUMENTS</b>

</P>

<P>This type of redirection instructs the shell to read input from the current source until a line containing only word (with

no trailing blanks) is seen. All of the lines read up to that point are then used as the standard input for a command.

</P>







<P><CENTER>

<a href="0020-0021.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0023-0024.html">Next</A></CENTER></P>







</td>
</tr>
</table>

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -