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

📄 special-chars.html

📁 一本完整的描述Unix Shell 编程的工具书的所有范例
💻 HTML
📖 第 1 页 / 共 5 页
字号:
></TD></TR></TABLE></DIV></DD><DT><SPANCLASS="TOKEN">-</SPAN></DT><DD><DIVCLASS="FORMALPARA"><P><B>previous working directory. </B>A <BCLASS="COMMAND">cd -</B> command changes to the		previous working directory. This uses the		<AHREF="variables2.html#OLDPWD">$OLDPWD</A> <AHREF="othertypesv.html#ENVREF">environmental variable</A>.</P></DIV><DIVCLASS="CAUTION"><TABLECLASS="CAUTION"WIDTH="90%"BORDER="0"><TR><TDWIDTH="25"ALIGN="CENTER"VALIGN="TOP"><IMGSRC="common/caution.png"HSPACE="5"ALT="Caution"></TD><TDALIGN="LEFT"VALIGN="TOP"><P>Do not confuse the <SPANCLASS="QUOTE">"-"</SPAN> used in this		sense with the <SPANCLASS="QUOTE">"-"</SPAN> redirection		operator just discussed. The interpretation of the		<SPANCLASS="QUOTE">"-"</SPAN> depends on the context in which it		appears.</P></TD></TR></TABLE></DIV></DD><DT><SPANCLASS="TOKEN">-</SPAN></DT><DD><DIVCLASS="FORMALPARA"><P><B>Minus. </B>Minus sign in an <AHREF="operations.html#AROPS1">arithmetic	        operation</A>.</P></DIV></DD><DT><SPANCLASS="TOKEN">=</SPAN></DT><DD><DIVCLASS="FORMALPARA"><P><B>Equals. </B><AHREF="varassignment.html#EQREF">Assignment operator</A>	        <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">   1&nbsp;a=28   2&nbsp;echo $a   # 28</PRE></TD></TR></TABLE></P></DIV><P>In a <AHREF="comparison-ops.html#EQUALSIGNREF">different context</A>,	      the <SPANCLASS="QUOTE">"<SPANCLASS="TOKEN">=</SPAN>"</SPAN> is a <AHREF="comparison-ops.html#SCOMPARISON1">string comparison</A>	      operator.</P></DD><DT><SPANCLASS="TOKEN">+</SPAN></DT><DD><DIVCLASS="FORMALPARA"><P><B>Plus. </B>Addition  <AHREF="operations.html#AROPS1">arithmetic	        operator</A>.</P></DIV><P>In a <AHREF="regexp.html#PLUSREF">different context</A>,	      the <SPANCLASS="TOKEN">+</SPAN> is a <AHREF="regexp.html">Regular	      Expression</A> operator.</P></DD><DT><SPANCLASS="TOKEN">+</SPAN></DT><DD><DIVCLASS="FORMALPARA"><P><B>Option. </B>Option flag for a command or filter.</P></DIV><P>Certain commands and <AHREF="internal.html#BUILTINREF">builtins</A> use the	      <SPANCLASS="TOKEN">+</SPAN> to enable certain options and the	      <SPANCLASS="TOKEN">-</SPAN> to disable them.</P></DD><DT><SPANCLASS="TOKEN">%</SPAN></DT><DD><DIVCLASS="FORMALPARA"><P><B><AHREF="operations.html#MODULOREF">modulo</A>. </B>Modulo (remainder of a division) <AHREF="operations.html#AROPS1">arithmetic	        operation</A>.</P></DIV><P>In a <AHREF="parameter-substitution.html#PCTPATREF">different context</A>,	      the <SPANCLASS="TOKEN">%</SPAN> is a <AHREF="parameter-substitution.html#PSUB2">pattern	      matching</A> operator.</P></DD><DT><SPANCLASS="TOKEN">~</SPAN></DT><DD><DIVCLASS="FORMALPARA"><P><B>home directory [tilde]. </B>This corresponds to the <AHREF="variables2.html#HOMEDIRREF">$HOME</A> internal variable.	      <ICLASS="EMPHASIS">~bozo</I> is bozo's home directory,		and <BCLASS="COMMAND">ls ~bozo</B> lists the contents of it.		<SPANCLASS="TOKEN">~/</SPAN> is the current user's home directory,		and <BCLASS="COMMAND">ls ~/</B> lists the contents of it.	      <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="SCREEN"> <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>echo ~bozo</B></TT> <TTCLASS="COMPUTEROUTPUT">/home/bozo</TT>  <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>echo ~</B></TT> <TTCLASS="COMPUTEROUTPUT">/home/bozo</TT>  <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>echo ~/</B></TT> <TTCLASS="COMPUTEROUTPUT">/home/bozo/</TT>  <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>echo ~:</B></TT> <TTCLASS="COMPUTEROUTPUT">/home/bozo:</TT>  <TTCLASS="PROMPT">bash$ </TT><TTCLASS="USERINPUT"><B>echo ~nonexistent-user</B></TT> <TTCLASS="COMPUTEROUTPUT">~nonexistent-user</TT> 	      </PRE></TD></TR></TABLE>	      </P></DIV></DD><DT><SPANCLASS="TOKEN">~+</SPAN></DT><DD><DIVCLASS="FORMALPARA"><P><B>current working directory. </B>This corresponds to the <AHREF="variables2.html#PWDREF">$PWD</A> internal variable.</P></DIV></DD><DT><SPANCLASS="TOKEN">~-</SPAN></DT><DD><DIVCLASS="FORMALPARA"><P><B>previous working directory. </B>This corresponds to the <AHREF="variables2.html#OLDPWD">$OLDPWD</A> internal variable.</P></DIV></DD><DT><SPANCLASS="TOKEN">=~</SPAN></DT><DD><DIVCLASS="FORMALPARA"><P><B><AHREF="bashver3.html#REGEXMATCHREF">regular	  expression match</A>. </B>This operator was introduced with <AHREF="bashver3.html#BASH3REF">version 3</A> of Bash.</P></DIV></DD><DT><SPANCLASS="TOKEN">^</SPAN></DT><DD><DIVCLASS="FORMALPARA"><P><B>beginning-of-line. </B>In a <AHREF="regexp.html#REGEXREF">regular expression</A>, a	        <SPANCLASS="QUOTE">"^"</SPAN> addresses the beginning of a line of text.</P></DIV></DD><DT>Control Characters</DT><DD><P><ANAME="CONTROLCHARREF"></A></P><DIVCLASS="FORMALPARA"><P><B> change the behavior of the	        terminal or text display. </B>A control character is a <BCLASS="KEYCAP">CONTROL</B>	      + <BCLASS="KEYCAP">key</B> combination.</P></DIV><P>Control characters are not normally useful inside a	    script.</P><UL><LI><P><TTCLASS="USERINPUT"><B>Ctl-B</B></TT></P><P>Backspace (nondestructive).</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-C</B></TT></P><P>Break. Terminate a foreground job.</P></LI><LI><P><ANAME="CTLDREF"></A></P><P><TTCLASS="USERINPUT"><B>Ctl-D</B></TT></P><P>Log out from a shell (similar to		  <AHREF="exit-status.html#EXITCOMMANDREF">exit</A>).</P><P><SPANCLASS="QUOTE">"EOF"</SPAN> (end of file). This also		  terminates input from <TTCLASS="FILENAME">stdin</TT>.</P><P>When typing text on the console or in an                  <ICLASS="FIRSTTERM">xterm</I> window,		  <TTCLASS="USERINPUT"><B>Ctl-D</B></TT> erases the character under the		  cursor. When there are no characters present,		  <TTCLASS="USERINPUT"><B>Ctl-D</B></TT> logs out of the session, as		  expected. In an xterm window, this has the effect of closing		  the window.</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-G</B></TT></P><P><SPANCLASS="QUOTE">"BEL"</SPAN> (beep). On some old-time teletype		  terminals, this would actually ring a bell.</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-H</B></TT></P><P><SPANCLASS="QUOTE">"Rubout"</SPAN> (destructive backspace). Erases		  characters the cursor backs over while backspacing.</P><P>		<TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">   1&nbsp;#!/bin/bash   2&nbsp;# Embedding Ctl-H in a string.   3&nbsp;   4&nbsp;a="^H^H"                  # Two Ctl-H's (backspaces).   5&nbsp;echo "abcdef"             # abcdef   6&nbsp;echo -n "abcdef$a "       # abcd f   7&nbsp;#  Space at end  ^              ^ Backspaces twice.   8&nbsp;echo -n "abcdef$a"        # abcdef   9&nbsp;#  No space at end                Doesn't backspace (why?).  10&nbsp;                          # Results may not be quite as expected.  11&nbsp;echo; echo</PRE></TD></TR></TABLE>                </P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-I</B></TT></P><P>Horizontal tab.</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-J</B></TT></P><P>Newline (line feed). In a script, may also be expressed		  in octal notation -- '\012' or in hexadecimal -- '\x0a'.</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-K</B></TT></P><P>Vertical tab.</P><P>When typing text on the console or in an                  <ICLASS="EMPHASIS">xterm</I> window,		  <TTCLASS="USERINPUT"><B>Ctl-K</B></TT> erases from the character		  under the cursor to end of line.</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-L</B></TT></P><P>Formfeed (clear the terminal screen). This has		  the same effect as the <AHREF="terminalccmds.html#CLEARREF">clear</A> command.</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-M</B></TT></P><P>Carriage return.</P><P>		<TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">   1&nbsp;#!/bin/bash   2&nbsp;# Thank you, Lee Maschmeyer, for this example.   3&nbsp;   4&nbsp;read -n 1 -s -p $'Control-M leaves cursor at beginning of this line. Press Enter. \x0d'   5&nbsp;                                  # Of course, '0d' is the hex equivalent of Control-M.   6&nbsp;echo &#62;&#38;2   #  The '-s' makes anything typed silent,   7&nbsp;           #+ so it is necessary to go to new line explicitly.   8&nbsp;   9&nbsp;read -n 1 -s -p $'Control-J leaves cursor on next line. \x0a'  10&nbsp;           #  '0a' is the hex equivalent of Control-J, linefeed.  11&nbsp;echo &#62;&#38;2  12&nbsp;  13&nbsp;###  14&nbsp;  15&nbsp;read -n 1 -s -p $'And Control-K\x0bgoes straight down.'  16&nbsp;echo &#62;&#38;2   #  Control-K is vertical tab.  17&nbsp;  18&nbsp;# A better example of the effect of a vertical tab is:  19&nbsp;  20&nbsp;var=$'\x0aThis is the bottom line\x0bThis is the top line\x0a'  21&nbsp;echo "$var"  22&nbsp;#  This works the same way as the above example. However:  23&nbsp;echo "$var" | col  24&nbsp;#  This causes the right end of the line to be higher than the left end.  25&nbsp;#  It also explains why we started and ended with a line feed --  26&nbsp;#+ to avoid a garbled screen.  27&nbsp;  28&nbsp;# As Lee Maschmeyer explains:  29&nbsp;# --------------------------  30&nbsp;#  In the [first vertical tab example] . . . the vertical tab  31&nbsp;#+ makes the printing go straight down without a carriage return.  32&nbsp;#  This is true only on devices, such as the Linux console,  33&nbsp;#+ that can't go "backward."  34&nbsp;#  The real purpose of VT is to go straight UP, not down.  35&nbsp;#  It can be used to print superscripts on a printer.  36&nbsp;#  The col utility can be used to emulate the proper behavior of VT.  37&nbsp;  38&nbsp;exit 0</PRE></TD></TR></TABLE>		</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-Q</B></TT></P><P>Resume (XON).</P><P>This resumes <TTCLASS="FILENAME">stdin</TT> in a terminal.</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-S</B></TT></P><P>Suspend (XOFF).</P><P>This freezes <TTCLASS="FILENAME">stdin</TT> in a terminal.		  (Use Ctl-Q to restore input.)</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-U</B></TT></P><P>Erase a line of input, from the cursor backward to		  beginning of line. In some settings,		  <TTCLASS="USERINPUT"><B>Ctl-U</B></TT> erases the entire		  line of input, <ICLASS="EMPHASIS">regardless of cursor		  position</I>.</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-V</B></TT></P><P>When inputting text, <TTCLASS="USERINPUT"><B>Ctl-V</B></TT>		  permits inserting control characters. For example, the		  following two are equivalent:		    <TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="90%"><TR><TD><PRECLASS="PROGRAMLISTING">   1&nbsp;echo -e '\x0a'   2&nbsp;echo &#60;Ctl-V&#62;&#60;Ctl-J&#62;</PRE></TD></TR></TABLE></P><P><TTCLASS="USERINPUT"><B>Ctl-V</B></TT> is primarily useful from		within a text editor.</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-W</B></TT></P><P>When typing text on the console or in an xterm window,		  <TTCLASS="USERINPUT"><B>Ctl-W</B></TT> erases from the character		  under the cursor backwards to the first instance of		  whitespace. In some settings, <TTCLASS="USERINPUT"><B>Ctl-W</B></TT>		  erases backwards to first non-alphanumeric character.</P></LI><LI><P><TTCLASS="USERINPUT"><B>Ctl-Z</B></TT></P><P>Pause a foreground job.</P></LI></UL></DD><DT>Whitespace</DT><DD><P><ANAME="WHITESPACEREF"></A></P><DIVCLASS="FORMALPARA"><P><B>functions as a separator, separating commands or variables. </B>Whitespace consists of either		<ICLASS="FIRSTTERM">spaces</I>,		<ICLASS="FIRSTTERM">tabs</I>, <ICLASS="FIRSTTERM">blank		lines</I>, or any combination thereof.		  <ANAME="AEN1676"HREF="#FTN.AEN1676">[3]</A>		In some contexts, such as <AHREF="gotchas.html#WSBAD">variable		assignment</A>, whitespace 

⌨️ 快捷键说明

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