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

📄 bashref.html

📁 Linux 下bash shell 参考
💻 HTML
📖 第 1 页 / 共 5 页
字号:
</P><P><OL><LI>Reads its input from a file (see section <A HREF="bashref.html#SEC54">3.8 Shell Scripts</A>), from a stringsupplied as an argument to the <SAMP>`-c'</SAMP> invocation option(see section <A HREF="bashref.html#SEC64">6.1 Invoking Bash</A>), or from the user's terminal.<P><LI>Breaks the input into words and operators, obeying the quoting rulesdescribed in <A HREF="bashref.html#SEC8">3.1.2 Quoting</A>.  These tokens are separated by<CODE>metacharacters</CODE>.  Alias expansion is performed by this step(see section <A HREF="bashref.html#SEC79">6.6 Aliases</A>).<P><LI>Parses the tokens into simple and compound commands(see section <A HREF="bashref.html#SEC15">3.2 Shell Commands</A>).<P><LI>Performs the various shell expansions (see section <A HREF="bashref.html#SEC26">3.5 Shell Expansions</A>), breakingthe expanded tokens into lists of filenames (see section <A HREF="bashref.html#SEC34">3.5.8 Filename Expansion</A>)and commands and arguments.<P><LI>Performs any necessary redirections (see section <A HREF="bashref.html#SEC37">3.6 Redirections</A>) and removesthe redirection operators and their operands from the argument list.<P><LI>Executes the command (see section <A HREF="bashref.html#SEC47">3.7 Executing Commands</A>).<P><LI>Optionally waits for the command to complete and collects its exitstatus (see section <A HREF="bashref.html#SEC52">3.7.5 Exit Status</A>).<P></OL><P><A NAME="Quoting"></A><HR SIZE="6"><A NAME="SEC8"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC7"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC9"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC14"> &lt;&lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC6"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC14"> &gt;&gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_About"> ? </A>]</TD></TR></TABLE><H3> 3.1.2 Quoting </H3><!--docid::SEC8::--><BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC9">3.1.2.1 Escape Character</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">How to remove the special meaning from a single			character.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC10">3.1.2.2 Single Quotes</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">How to inhibit all interpretation of a sequence			of characters.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC11">3.1.2.3 Double Quotes</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">How to suppress most of the interpretation of a			sequence of characters.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC12">3.1.2.4 ANSI-C Quoting</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">How to expand ANSI-C sequences in quoted strings.</TD></TR></TABLE><br><TABLE BORDER=0 CELLSPACING=0><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC13">3.1.2.5 Locale-Specific Translation</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">How to translate strings into different languages.</TD></TR></TABLE></BLOCKQUOTE><P>Quoting is used to remove the special meaning of certaincharacters or words to the shell.  Quoting can be used todisable special treatment for special characters, to preventreserved words from being recognized as such, and to preventparameter expansion.</P><P>Each of the shell metacharacters (see section <A HREF="bashref.html#SEC4">2. Definitions</A>)has special meaning to the shell and must be quoted if it is torepresent itself.When the command history expansion facilities are being used, the<VAR>history expansion</VAR> character, usually <SAMP>`!'</SAMP>, must be quotedto prevent history expansion.  See section <A HREF="bashref.html#SEC115">9.1 Bash History Facilities</A>, formore details concerning history expansion.There are three quoting mechanisms: the<VAR>escape character</VAR>, single quotes, and double quotes.</P><P><A NAME="Escape Character"></A><HR SIZE="6"><A NAME="SEC9"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC8"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC10"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC14"> &lt;&lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC8"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC14"> &gt;&gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_About"> ? </A>]</TD></TR></TABLE><H4> 3.1.2.1 Escape Character </H4><!--docid::SEC9::-->A non-quoted backslash <SAMP>`\'</SAMP> is the Bash escape character.It preserves the literal value of the next character that follows,with the exception of <CODE>newline</CODE>.  If a <CODE>\newline</CODE> pairappears, and the backslash itself is not quoted, the <CODE>\newline</CODE>is treated as a line continuation (that is, it is removed fromthe input stream and effectively ignored).<P><A NAME="Single Quotes"></A><HR SIZE="6"><A NAME="SEC10"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC9"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC11"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC11"> &lt;&lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC8"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC14"> &gt;&gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_About"> ? </A>]</TD></TR></TABLE><H4> 3.1.2.2 Single Quotes </H4><!--docid::SEC10::--><P>Enclosing characters in single quotes (<SAMP>`''</SAMP>) preserves the literal valueof each character within the quotes.  A single quote may not occurbetween single quotes, even when preceded by a backslash.</P><P><A NAME="Double Quotes"></A><HR SIZE="6"><A NAME="SEC11"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC10"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC12"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC12"> &lt;&lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC8"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC14"> &gt;&gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_About"> ? </A>]</TD></TR></TABLE><H4> 3.1.2.3 Double Quotes </H4><!--docid::SEC11::--><P>Enclosing characters in double quotes (<SAMP>`"'</SAMP>) preserves the literal valueof all characters within the quotes, with the exception of<SAMP>`$'</SAMP>, <SAMP>``'</SAMP>, and <SAMP>`\'</SAMP>.The characters <SAMP>`$'</SAMP> and <SAMP>``'</SAMP>retain their special meaning within double quotes (see section <A HREF="bashref.html#SEC26">3.5 Shell Expansions</A>).The backslash retains its special meaning only when followed by one ofthe following characters:<SAMP>`$'</SAMP>, <SAMP>``'</SAMP>, <SAMP>`"'</SAMP>, <SAMP>`\'</SAMP>, or <CODE>newline</CODE>.Within double quotes, backslashes that are followed by one of thesecharacters are removed.  Backslashes preceding characters without aspecial meaning are left unmodified.A double quote may be quoted within double quotes by preceding it witha backslash.</P><P>The special parameters <SAMP>`*'</SAMP> and <SAMP>`@'</SAMP> have special meaningwhen in double quotes (see section <A HREF="bashref.html#SEC29">3.5.3 Shell Parameter Expansion</A>).</P><P><A NAME="ANSI-C Quoting"></A><HR SIZE="6"><A NAME="SEC12"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC11"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC13"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC13"> &lt;&lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC8"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC14"> &gt;&gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_About"> ? </A>]</TD></TR></TABLE><H4> 3.1.2.4 ANSI-C Quoting </H4><!--docid::SEC12::--><P>Words of the form <CODE>$'<VAR>string</VAR>'</CODE> are treated specially.  Theword expands to <VAR>string</VAR>, with backslash-escaped characters replacedas specified by the ANSI C standard.  Backslash escape sequences, ifpresent, are decoded as follows:</P><P><DL COMPACT><DT><CODE>\a</CODE><DD>alert (bell)<DT><CODE>\b</CODE><DD>backspace<DT><CODE>\e</CODE><DD>an escape character (not ANSI C)<DT><CODE>\f</CODE><DD>form feed<DT><CODE>\n</CODE><DD>newline<DT><CODE>\r</CODE><DD>carriage return<DT><CODE>\t</CODE><DD>horizontal tab<DT><CODE>\v</CODE><DD>vertical tab<DT><CODE>\\</CODE><DD>backslash<DT><CODE>\'</CODE><DD>single quote<DT><CODE>\<VAR>nnn</VAR></CODE><DD>the eight-bit character whose value is the octal value <VAR>nnn</VAR>(one to three digits)<DT><CODE>\x<VAR>HH</VAR></CODE><DD>the eight-bit character whose value is the hexadecimal value <VAR>HH</VAR>(one or two hex digits)<DT><CODE>\c<VAR>x</VAR></CODE><DD>a control-<VAR>x</VAR> character</DL><P>The expanded result is single-quoted, as if the dollar sign had notbeen present.</P><P><A NAME="Locale Translation"></A><HR SIZE="6"><A NAME="SEC13"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC12"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC14"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC14"> &lt;&lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC8"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC14"> &gt;&gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Top">Top</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Contents">Contents</A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[Index]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_About"> ? </A>]</TD></TR></TABLE><H4> 3.1.2.5 Locale-Specific Translation </H4><!--docid::SEC13::--><P>A double-quoted string preceded by a dollar sign (<SAMP>`$'</SAMP>) will causethe string to be translated according to the current locale.If the current locale is <CODE>C</CODE> or <CODE>POSIX</CODE>, the dollar signis ignored.If the string is translated and replaced, the replacement isdouble-quoted.</P><P><A NAME="IDX21"></A><A NAME="IDX22"></A><A NAME="IDX23"></A>Some systems use the message catalog selected by the <CODE>LC_MESSAGES</CODE>shell variable.  Others create the name of the message catalog from thevalue of the <CODE>TEXTDOMAIN</CODE> shell variable, possibly adding asuffix of <SAMP>`.mo'</SAMP>.  If you use the <CODE>TEXTDOMAIN</CODE> variable, youmay need to set the <CODE>TEXTDOMAINDIR</CODE> variable to the location ofthe message catalog files.  Still others use both variables in thisfashion:<CODE>TEXTDOMAINDIR</CODE>/<CODE>LC_MESSAGES</CODE>/LC_MESSAGES/<CODE>TEXTDOMAIN</CODE>.mo.

⌨️ 快捷键说明

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