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

📄 bashref.html

📁 Linux 下bash shell 参考
💻 HTML
📖 第 1 页 / 共 5 页
字号:
While executing commands is essential, most of the power (andcomplexity) of shells is due to their embedded programminglanguages.  Like any high-level language, the shell providesvariables, flow control constructs, quoting, and functions. </P><P>Shells offer features geared specifically forinteractive use rather than to augment the programming language. These interactive features include job control, command lineediting, history and aliases.  Each of these features isdescribed in this manual.</P><P><A NAME="Definitions"></A><HR SIZE="6"><A NAME="SEC4"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC3"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC5"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC5"> &lt;&lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Top"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC5"> &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><H1> 2. Definitions </H1><!--docid::SEC4::-->These definitions are used throughout the remainder of this manual.<P><DL COMPACT><DT><CODE>POSIX</CODE><DD><A NAME="IDX1"></A>A family of open system standards based on Unix.  Bashis concerned with POSIX 1003.2, the Shell and Tools Standard.<P><DT><CODE>blank</CODE><DD>A space or tab character.<P><DT><CODE>builtin</CODE><DD><A NAME="IDX2"></A>A command that is implemented internally by the shell itself, ratherthan by an executable program somewhere in the file system.<P><DT><CODE>control operator</CODE><DD><A NAME="IDX3"></A>A <CODE>word</CODE> that performs a control function.  It is a <CODE>newline</CODE>or one of the following:<SAMP>`||'</SAMP>, <SAMP>`&#38;&#38;'</SAMP>, <SAMP>`&#38;'</SAMP>, <SAMP>`;'</SAMP>, <SAMP>`;;'</SAMP>,<SAMP>`|'</SAMP>, <SAMP>`('</SAMP>, or <SAMP>`)'</SAMP>.<P><DT><CODE>exit status</CODE><DD><A NAME="IDX4"></A>The value returned by a command to its caller.  The value is restrictedto eight bits, so the maximum value is 255.<P><DT><CODE>field</CODE><DD><A NAME="IDX5"></A>A unit of text that is the result of one of the shell expansions.  Afterexpansion, when executing a command, the resulting fields are used asthe command name and arguments.<P><DT><CODE>filename</CODE><DD><A NAME="IDX6"></A>A string of characters used to identify a file.<P><DT><CODE>job</CODE><DD><A NAME="IDX7"></A>A set of processes comprising a pipeline, and any processes descendedfrom it, that are all in the same process group.<P><DT><CODE>job control</CODE><DD><A NAME="IDX8"></A>A mechanism by which users can selectively stop (suspend) and restart(resume) execution of processes.<P><DT><CODE>metacharacter</CODE><DD><A NAME="IDX9"></A>A character that, when unquoted, separates words.  A metacharacter isa <CODE>blank</CODE> or one of the following characters:<SAMP>`|'</SAMP>, <SAMP>`&#38;'</SAMP>, <SAMP>`;'</SAMP>, <SAMP>`('</SAMP>, <SAMP>`)'</SAMP>, <SAMP>`&#60;'</SAMP>, or<SAMP>`&#62;'</SAMP>.<P><DT><CODE>name</CODE><DD><A NAME="IDX10"></A><A NAME="IDX11"></A>A <CODE>word</CODE> consisting solely of letters, numbers, and underscores,and beginning with a letter or underscore.  <CODE>Name</CODE>s are used asshell variable and function names.Also referred to as an <CODE>identifier</CODE>.<P><DT><CODE>operator</CODE><DD><A NAME="IDX12"></A>A <CODE>control operator</CODE> or a <CODE>redirection operator</CODE>.See section <A HREF="bashref.html#SEC37">3.6 Redirections</A>, for a list of redirection operators.<P><DT><CODE>process group</CODE><DD><A NAME="IDX13"></A>A collection of related processes each having the same processgroup ID.<P><DT><CODE>process group ID</CODE><DD><A NAME="IDX14"></A>A unique identifer that represents a <CODE>process group</CODE>during its lifetime.<P><DT><CODE>reserved word</CODE><DD><A NAME="IDX15"></A>A <CODE>word</CODE> that has a special meaning to the shell.  Most reservedwords introduce shell flow control constructs, such as <CODE>for</CODE> and<CODE>while</CODE>.<P><DT><CODE>return status</CODE><DD><A NAME="IDX16"></A>A synonym for <CODE>exit status</CODE>.<P><DT><CODE>signal</CODE><DD><A NAME="IDX17"></A>A mechanism by which a process may be notified by the kernelof an event occurring in the system.<P><DT><CODE>special builtin</CODE><DD><A NAME="IDX18"></A>A shell builtin command that has been classified as special by thePOSIX 1003.2 standard.<P><DT><CODE>token</CODE><DD><A NAME="IDX19"></A>A sequence of characters considered a single unit by the shell.  It iseither a <CODE>word</CODE> or an <CODE>operator</CODE>.<P><DT><CODE>word</CODE><DD><A NAME="IDX20"></A>A <CODE>token</CODE> that is not an <CODE>operator</CODE>.</DL><P><A NAME="Basic Shell Features"></A><HR SIZE="6"><A NAME="SEC5"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC4"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC6"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC55"> &lt;&lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC_Top"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC55"> &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><H1> 3. Basic Shell Features </H1><!--docid::SEC5::--><P>Bash is an acronym for <SAMP>`Bourne-Again SHell'</SAMP>.The Bourne shell isthe traditional Unix shell originally written by Stephen Bourne.All of the Bourne shell builtin commands are available in Bash,and the rules for evaluation and quoting are taken from the POSIX1003.2 specification for the `standard' Unix shell.</P><P>This chapter briefly summarizes the shell's `building blocks':commands, control structures, shell functions, shell <I>parameters</I>,shell expansions,<I>redirections</I>, which are a way to direct input and output fromand to named files, and how the shell executes commands.</P><P><BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC6">3.1 Shell Syntax</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">What your input means to the shell.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC15">3.2 Shell Commands</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">The types of commands you can use.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC22">3.3 Shell Functions</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Grouping commands by name.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC23">3.4 Shell Parameters</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Special shell variables.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC26">3.5 Shell Expansions</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">How Bash expands variables and the various				expansions available.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC37">3.6 Redirections</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">A way to control where input and output go.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC47">3.7 Executing Commands</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">What happens when you run a command.</TD></TR><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC54">3.8 Shell Scripts</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">Executing files of shell commands.</TD></TR></TABLE></BLOCKQUOTE><P><A NAME="Shell Syntax"></A><HR SIZE="6"><A NAME="SEC6"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC5"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC7"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC5"> &lt;&lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC5"> Up </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC15"> &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><H2> 3.1 Shell Syntax </H2><!--docid::SEC6::--><BLOCKQUOTE><TABLE BORDER=0 CELLSPACING=0> <TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC7">3.1.1 Shell Operation</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">The basic operation of the shell.</TD></TR></TABLE><br><TABLE BORDER=0 CELLSPACING=0><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC8">3.1.2 Quoting</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">How to remove the special meaning from characters.</TD></TR></TABLE><br><TABLE BORDER=0 CELLSPACING=0><TR><TD ALIGN="left" VALIGN="TOP"><A HREF="bashref.html#SEC14">3.1.3 Comments</A></TD><TD>&nbsp;&nbsp;</TD><TD ALIGN="left" VALIGN="TOP">How to specify comments.</TD></TR></TABLE></BLOCKQUOTE><P>When the shell reads input, it proceeds through asequence of operations.  If the input indicates the beginning of acomment, the shell ignores the comment symbol (<SAMP>`#'</SAMP>), and the restof that line.                                Otherwise, roughly speaking,  the shell reads its input anddivides the input into words and operators, employing the quoting rulesto select which meanings to assign various words and characters.</P><P>The shell then parses these tokens into commands and other constructs,removes the special meaning of certain words or characters, expandsothers, redirects input and output as needed, executes the specifiedcommand, waits for the command's exit status, and makes that exit statusavailable for further inspection or processing.</P><P><A NAME="Shell Operation"></A><HR SIZE="6"><A NAME="SEC7"></A><TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0><TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC6"> &lt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC8"> &gt; </A>]</TD><TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="bashref.html#SEC5"> &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#SEC15"> &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.1 Shell Operation </H3><!--docid::SEC7::--><P>The following is a brief description of the shell's operation when itreads and executes a command.  Basically, the shell does thefollowing:

⌨️ 快捷键说明

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