{"id":1838,"date":"2015-01-24T01:45:25","date_gmt":"2015-01-23T17:45:25","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=1838"},"modified":"2015-01-24T01:45:25","modified_gmt":"2015-01-23T17:45:25","slug":"bash%e4%b8%ad%e7%9a%84%e7%89%b9%e6%ae%8a%e5%ad%97%e7%ac%a6","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/1838.html","title":{"rendered":"Bash\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26"},"content":{"rendered":"<p>\u5f88\u65e9\u4e4b\u524d\u5728blog\u4e2d\u5c31\u8bb0\u5f55\u8fc7\u4e00\u7bc7\u6587\u7ae0\uff1a<a href=\"http:\/\/ixyzero.com\/blog\/archives\/119.html\" target=\"_blank\">Linux Shell\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26<\/a>\uff0c\u4f46\u89c9\u5f97\u603b\u7ed3\u5f97\u8fd8\u4e0d\u591f\u2014\u2014\u4e0d\u591f\u76f4\u63a5\uff0c\u6240\u4ee5\u540e\u6765\u53c8\u53bb\u7f51\u4e0a\u641c\u4e86\u641c\uff0c\u8fd8\u771f\u662f\u627e\u5230\u4e86\u4e0d\u5c11\u76f8\u5173\u5185\u5bb9\uff0c\u4e4b\u524d\u77e5\u9053\u7684\u8fd8\u662f\u592a\u5c11\u4e86o(\u256f\u25a1\u2570)o \u5b66\u65e0\u6b62\u5883\uff0c\u6162\u6162\u6765\u5427\u2026\u2026<\/p>\n<h6>\u641c\u7d22\u5173\u952e\u5b57\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/search.aol.com\/aol\/search?q=special+character+in+bash\" target=\"_blank\">http:\/\/search.aol.com\/aol\/search?q=special+character+in+bash<\/a><\/li>\n<li><a href=\"http:\/\/search.aol.com\/aol\/search?q=special+characters+list+in+bash\" target=\"_blank\">http:\/\/search.aol.com\/aol\/search?q=special+characters+list+in+bash<\/a><\/li>\n<li><a href=\"http:\/\/search.aol.com\/aol\/search?q=special+characters+in+unix+bash+shell\" target=\"_blank\">http:\/\/search.aol.com\/aol\/search?q=special+characters+in+unix+bash+shell<\/a><\/li>\n<\/ul>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_19.htm\" target=\"_blank\">[Chapter 8] 8.19 &#8220;Special&#8221; Characters and Operators<\/a><\/li>\n<li><a href=\"http:\/\/www.grymoire.com\/Unix\/Sh.html#toc-uh-4\" target=\"_blank\">Meta-characters and Filename expansion<\/a><br \/>\n<a href=\"http:\/\/www.gnu.org\/software\/bash\/manual\/bashref.html\">Bash Reference Manual<\/a><\/li>\n<li><a href=\"http:\/\/mywiki.wooledge.org\/BashGuide\/SpecialCharacters\" target=\"_blank\">BashGuide\/SpecialCharacters &#8211; Greg&#8217;s Wiki <\/a>\u00a0#\u8fd9\u4e2awiki\u633a\u725b\u903c\u7684\uff01<\/li>\n<li><a href=\"http:\/\/tldp.org\/LDP\/abs\/html\/special-chars.html\" target=\"_blank\">Special Characters<\/a>\u00a0\u00a0#\u5b98\u65b9\u8bf4\u660e\uff01<\/li>\n<li><a href=\"http:\/\/tldp.org\/LDP\/abs\/html\/internal.html\" target=\"_blank\">Internal Commands and Builtins <\/a>\u00a0#Bash\u7684\u5185\u5efa\u547d\u4ee4<\/li>\n<li><a href=\"http:\/\/tldp.org\/LDP\/abs\/html\/x17129.html\" target=\"_blank\">A Brief Introduction to Regular Expressions <\/a>\u00a0#Bash\u4e2d\u7684\u6b63\u5219\u8868\u8fbe\u5f0f<\/li>\n<\/ul>\n<h6>\u76f8\u5173\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/15783701\/which-characters-need-to-be-escaped-in-bash-how-do-we-know-it\" target=\"_blank\">shell &#8211; Which characters need to be escaped in Bash? How do we know it? &#8211; Stack Overflow<\/a><\/li>\n<li><a href=\"http:\/\/www.commandlinefu.com\/commands\/view\/4589\/command-to-show-a-list-of-special-characters-for-bash-prompt-ps1\" target=\"_blank\">http:\/\/www.commandlinefu.com\/commands\/view\/4589\/command-to-show-a-list-of-special-characters-for-bash-prompt-ps1<\/a><\/li>\n<li><a href=\"http:\/\/javarevisited.blogspot.com\/2011\/06\/special-bash-parameters-in-script-linux.html\" target=\"_blank\">http:\/\/javarevisited.blogspot.com\/2011\/06\/special-bash-parameters-in-script-linux.html<\/a><\/li>\n<li><a href=\"http:\/\/www.linuxquestions.org\/questions\/linux-general-1\/using-special-symbols-in-bash-script-683387\/\" target=\"_blank\">using special symbols in bash script<\/a><\/li>\n<\/ul>\n<hr \/>\n<h5>Special characters<\/h5>\n<p>A group of characters have been exempted, that when we use them, they are evaluated by <a href=\"http:\/\/mywiki.wooledge.org\/Bash\" target=\"_blank\">Bash<\/a> to have a non-literal meaning. Instead, these characters carry out a special instruction, or have an alternate meaning; they are called &#8220;<span style=\"color: #ff0000;\"><strong>special characters<\/strong><\/span>&#8220;, or &#8220;<span style=\"color: #ff0000;\"><strong>meta-characters<\/strong><\/span>&#8220;.<\/p>\n<p>To explain the special characters in all the cases in which they may be used, read the section on the <a href=\"http:\/\/www.tldp.org\/LDP\/abs\/html\/special-chars.html\" target=\"_blank\">TLDP guide<\/a>. Here are some of the more common special characters uses:<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"56\">Char.<\/td>\n<td width=\"505\">Description<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">&#8221; &#8220;<\/td>\n<td width=\"505\">Whitespace \u2014 this is a tab, newline, vertical tab, form feed, carriage return, or space. <span style=\"color: #ff0000;\">Bash uses whitespace to determine where words begin and end.<\/span> The first word is the command name and additional words become arguments to that command.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">$<\/td>\n<td width=\"505\">Expansion \u2014 introduces various types of expansion: <span style=\"color: #ff0000;\"><strong>parameter expansion<\/strong><\/span> (e.g. $var or ${var}), <strong><a href=\"http:\/\/mywiki.wooledge.org\/CommandSubstitution\" target=\"_blank\">command substitution<\/a><\/strong> (e.g. $(command)), or <span style=\"color: #ff0000;\"><strong>arithmetic expansion<\/strong><\/span> (e.g. $((expression))). More on expansions later.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">&#8221;<\/td>\n<td width=\"505\">Single quotes \u2014 protect the text inside them so that it has a literal meaning. With them, generally any kind of interpretation by Bash is ignored: special characters are passed over and multiple words are prevented from being split.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">&#8220;&#8221;<\/td>\n<td width=\"505\">Double quotes \u2014 protect the text inside them from being split into multiple words or arguments, yet allow substitutions to occur; the meaning of most other special characters is usually prevented.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">\\<\/td>\n<td width=\"505\">Escape \u2014 (backslash) prevents the next character from being interpreted as a special character. This works outside of quoting, inside double quotes, and generally ignored in single quotes.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">#<\/td>\n<td width=\"505\">Comment \u2014 an introduction of a # character begins a commentary that extends to the end of the line. Comments are notes of explanation and are not processed by the shell.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">[[]]<\/td>\n<td width=\"505\">Test \u2014 an evaluation of a conditional expression to determine whether it is &#8220;true&#8221; or &#8220;false&#8221;. Tests are used in Bash to evaluate a number of conditions. More of this will be covered later.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">!<\/td>\n<td width=\"505\">Negate \u2014 <span style=\"color: #ff0000;\">used to negate or reverse a test or exit status<\/span>. For example: ! grep text file; exit $?.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">&gt;&lt;<\/td>\n<td width=\"505\">Redirection \u2014 redirect a command&#8217;s output or input. Redirections will be covered later.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">|<\/td>\n<td width=\"505\">Pipe \u2014 redirect output from a initial command to the input of secondary command. This is a method of chaining commands together. Example: echo &#8220;Hello beautiful.&#8221; | grep -o beautiful.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">;<\/td>\n<td width=\"505\">Command separator \u2014 a representation of a newline. Used to separate multiple commands that are on the same line.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">{}<\/td>\n<td width=\"505\"><span style=\"color: #ff0000;\">Inline group \u2014 commands inside the curly braces are treated as if they were one command.<\/span> It is convenient to use these when Bash syntax requires only one command and a function doesn&#8217;t feel warranted.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">()<\/td>\n<td width=\"505\"><span style=\"color: #ff0000;\">Subshell group \u2014 similar to the above but where commands within are executed in subshell.<\/span> Used much like a <span style=\"color: #ff0000;\"><strong>sandbox<\/strong><\/span>, if a command causes side effects (like changing variables), it will have no effect on the current shell.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">(())<\/td>\n<td width=\"505\">Arithmetic expression \u2014 with an <a href=\"http:\/\/mywiki.wooledge.org\/ArithmeticExpression\">arithmetic expression<\/a>, characters such as +, -, *, and \/ are mathematical operators used for calculations. They can be used for variable assignments like (( a = 1 + 4 )) as well as tests like if (( a &lt; b )). More on this later.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">$(())<\/td>\n<td width=\"505\">Arithmetic expansion \u2014 Comparable to the above, but the expression is replaced with the result of its arithmetic evaluation. Example: echo &#8220;The average is $(( (a+b)\/2 ))&#8221;.<\/td>\n<\/tr>\n<tr>\n<td width=\"56\">~<\/td>\n<td width=\"505\">Home directory \u2014 the tilde is a representation of the home directory. When followed by a \/, it means the current user&#8217;s home directory; otherwise, a username will have to be specified (e.g.ls ~\/Documents; cp ~john\/.bashrc .).<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h6>Examples:<\/h6>\n<pre class=\"lang:default decode:true  \">$ echo \"I am $LOGNAME\"\nI am lhunath\n$ echo 'I am $LOGNAME'\nI am $LOGNAME\n$ # boo\n$ echo An open\\ \\ \\ space\nAn open   space\n$ echo \"My computer is $(hostname)\"\nMy computer is Lyndir\n$ echo boo &gt; file\n$ echo $(( 5 + 5 ))\n10\n$ (( 5 &gt; 0 )) &amp;&amp; echo \"Five is greater than zero.\"\nFive is greater than zero.<\/pre>\n<h6>Additionally:<\/h6>\n<p>In The Manual \u2014 <a href=\"http:\/\/www.gnu.org\/software\/bash\/manual\/html_node\/Shell-Syntax.html#Shell-Syntax\" target=\"_blank\">Shell Syntax<\/a><\/p>\n<p>Special Characters \u2014 Characters that have a special meaning to Bash. Usually their meaning is interpreted and then they are removed from the command before executing it.<\/p>\n<hr \/>\n<p>\u6700\u540e\u6765\u5f20\u4ece\u7f51\u4e0a\u627e\u5230\u7684\u8868\u683c\uff0c\u66f4\u52a0\u76f4\u89c2\u7684\u663e\u793a\u51fashell\uff08\u867d\u7136\u662fcsh\u548csh\u7684\uff0c\u4f46Bash\u4e5f\u5927\u4f53\u76f8\u540c\uff0c\u53ea\u6709\u5c11\u8bb8\u5dee\u5f02\uff09\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26\uff1a<\/p>\n<p><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_19.htm#UPT-ART-419-TAB-0\" target=\"_blank\">Table 8.3<\/a> is a table of special characters and operators in the C shell ( csh ) and Bourne shell ( sh ). The chart also includes several combinations of characters just to be complete. As in other parts of this book, the sh entries apply to ksh and bash ; the csh entries apply to tcsh .<\/p>\n<table>\n<tbody>\n<tr>\n<td colspan=\"4\" width=\"563\">\n<h6><span style=\"color: #0000ff;\"><strong>List of Special Characters and Their Meanings<\/strong><\/span><\/h6>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"99\">Character<\/td>\n<td width=\"83\">Where<\/td>\n<td width=\"284\">Meaning<\/td>\n<td width=\"90\">Article<\/td>\n<\/tr>\n<tr>\n<td width=\"99\">ESC<\/td>\n<td width=\"83\">csh<\/td>\n<td width=\"284\">Filename completion.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_08.htm\">9.8<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">RETURN<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Execute command.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch41_02.htm\">41.2<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">space<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Argument separator.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_05.htm\">8.5<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">TAB<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Argument separator.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_05.htm\">8.5<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">TAB<\/td>\n<td width=\"83\">bash<\/td>\n<td width=\"284\">Filename completion.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_08.htm\">9.8<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">#<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Start a comment.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch44_02.htm\">44.2<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">`<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Command substitution (backquotes).<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_16.htm\">9.16<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&#8220;<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Weak quotes.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_14.htm\">8.14<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&#8220;<\/td>\n<td width=\"83\">csh<\/td>\n<td width=\"284\">Weak quotes.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_15.htm\">8.15<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_14.htm\">8.14<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&#8216;<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Strong quotes.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_14.htm\">8.14<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&#8216;<\/td>\n<td width=\"83\">csh<\/td>\n<td width=\"284\">Strong quotes.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_15.htm\">8.15<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_14.htm\">8.14<\/a> See \\.<\/td>\n<\/tr>\n<tr>\n<td width=\"99\">\\<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Single-character quote.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_14.htm\">8.14<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">\\<\/td>\n<td width=\"83\">csh<\/td>\n<td width=\"284\">Single-character quote.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_15.htm\">8.15<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_14.htm\">8.14<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">$ var<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Variable.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch06_01.htm#UPT-ART-1170\">6.1<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch06_08.htm\">6.8<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">${ var }<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Same as $ var .<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch06_08.htm\">6.8<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">$ var : mod<\/td>\n<td width=\"83\">csh<\/td>\n<td width=\"284\">Edit var with modifier mod<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_06.htm\">9.6<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">${ var &#8211; default }<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">If var not set, use default .<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_12.htm\">45.12<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">${ var = default }<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">If var not set, set it to default and use that value.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_12.htm\">45.12<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">${ var + instead }<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">If var set, use instead . Otherwise, null string.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_12.htm\">45.12<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">${ var ? message }<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">If var not set, print message (else default). If var set, use its value.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_12.htm\">45.12<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">${ var # pat }<\/td>\n<td width=\"83\">ksh, bash<\/td>\n<td width=\"284\">Value of var with smallest pat deleted from start.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_07.htm\">9.7<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">${ var ## pat }<\/td>\n<td width=\"83\">ksh, bash<\/td>\n<td width=\"284\">Value of var with largest pat deleted from start.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_07.htm\">9.7<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">${ var % pat }<\/td>\n<td width=\"83\">ksh, bash<\/td>\n<td width=\"284\">Value of var with smallest pat deleted from end.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_07.htm\">9.7<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">${ var %% pat }<\/td>\n<td width=\"83\">ksh, bash<\/td>\n<td width=\"284\">Value of var with largest pat deleted from end.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_07.htm\">9.7<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">|<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Pipe standard output.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch01_04.htm\">1.4<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch13_01.htm#UPT-ART-1023\">13.1<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">|&amp;<\/td>\n<td width=\"83\">csh<\/td>\n<td width=\"284\">Pipe standard output and standard error.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch13_05.htm\">13.5<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">^<\/td>\n<td width=\"83\">sh only<\/td>\n<td width=\"284\">Pipe character (obsolete).<\/td>\n<td width=\"90\"><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">^<\/td>\n<td width=\"83\">csh, bash<\/td>\n<td width=\"284\">Edit previous command line.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch11_05.htm\">11.5<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&amp;<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Run program in background.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch01_27.htm\">1.27<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch01_28.htm\">1.28<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">?<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Match one character.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch01_16.htm\">1.16<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch15_02.htm\">15.2<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">*<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Match zero or more characters.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch01_16.htm\">1.16<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch15_02.htm\">15.2<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">;<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Command separator.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_05.htm\">8.5<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">;;<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">End of case statement.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch44_05.htm\">44.5<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">~<\/td>\n<td width=\"83\">csh, ksh, bash<\/td>\n<td width=\"284\">Home directory.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch14_11.htm\">14.11<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">~ user<\/td>\n<td width=\"83\">csh, ksh, bash<\/td>\n<td width=\"284\">Home directory of user .<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch14_11.htm\">14.11<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">!<\/td>\n<td width=\"83\">csh, bash<\/td>\n<td width=\"284\">Command history.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch11_02.htm\">11.2<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&#8211;<\/td>\n<td width=\"83\">Programs<\/td>\n<td width=\"284\">Start of optional argument.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_05.htm\">8.5<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&#8211;<\/td>\n<td width=\"83\">Programs<\/td>\n<td width=\"284\">Read standard input. (Only certain programs.)<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch13_13.htm\">13.13<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">$#<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Number of arguments to script.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch44_15.htm\">44.15<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&#8220;$@&#8221;<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Original arguments to script.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch44_15.htm\">44.15<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">$*<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Arguments to script.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch44_15.htm\">44.15<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">$-<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Flags set in shell.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch02_11.htm\">2.11<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">$?<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Status of previous command.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch44_07.htm\">44.7<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">$$<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Process identification number.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_14.htm\">8.14<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">$!<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Process identification number of last background job.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch07_12.htm\">7.12<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">$&lt;<\/td>\n<td width=\"83\">csh<\/td>\n<td width=\"284\">Read input from terminal.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_11.htm\">9.11<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">cmd1 &amp;&amp; cmd2<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Execute cmd2 if cmd1 succeeds.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch44_09.htm\">44.9<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">cmd1 || cmd2<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Execute cmd2 if cmd1 fails.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch44_09.htm\">44.9<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">$(..)<\/td>\n<td width=\"83\">ksh, bash<\/td>\n<td width=\"284\">Command substitution.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_31.htm\">45.31<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_16.htm\">9.16<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">((..))<\/td>\n<td width=\"83\">ksh, bash<\/td>\n<td width=\"284\">Arithmetic evaluation.<\/td>\n<td width=\"90\"><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">\\. file<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Execute commands from file in this shell.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch44_23.htm\">44.23<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">:<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Evaluate arguments, return true.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_09.htm\">45.9<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">:<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Separate values in paths.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch06_04.htm\">6.4<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch14_05.htm\">14.5<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch21_08.htm\">21.8<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">:<\/td>\n<td width=\"83\">csh<\/td>\n<td width=\"284\">Variable modifier.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_06.htm\">9.6<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">[]<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Match range of characters.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch01_16.htm\">1.16<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch15_02.htm\">15.2<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">[]<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Test.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch44_20.htm\">44.20<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">% job<\/td>\n<td width=\"83\">csh, ksh, bash<\/td>\n<td width=\"284\">Identify job number.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch12_01.htm#UPT-ART-0439\">12.1<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">( cmd ; cmd )<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Run cmd ; cmd in a subshell.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch13_07.htm\">13.7<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">{}<\/td>\n<td width=\"83\">csh, bash<\/td>\n<td width=\"284\">In-line expansions.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_05.htm\">9.5<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">{ cmd ; cmd ; }<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Like ( cmd ; cmd ) without a subshell.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch13_08.htm\">13.8<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&gt; file<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Redirect standard output.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch13_01.htm#UPT-ART-1023\">13.1<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&gt;&gt; file<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Append standard output.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch13_01.htm#UPT-ART-1023\">13.1<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&lt; file<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Redirect standard input.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch13_01.htm#UPT-ART-1023\">13.1<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&lt;&lt; word<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Read until word , do command and variable substitution.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_18.htm\">8.18<\/a> , <a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch09_14.htm\">9.14<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&lt;&lt;\\ word<\/td>\n<td width=\"83\">csh, sh<\/td>\n<td width=\"284\">Read until word , no substitution.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_18.htm\">8.18<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&lt;&lt;- word<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Read until word , ignoring leading TABs.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch08_18.htm\">8.18<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&gt;&gt;!\u00a0 file<\/td>\n<td width=\"83\">csh<\/td>\n<td width=\"284\">Append to file , even if noclobber set and file doesn&#8217;t exist.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch13_06.htm\">13.6<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&gt;!\u00a0 file<\/td>\n<td width=\"83\">csh<\/td>\n<td width=\"284\">Output to file , even if noclobber set and file exists.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch13_06.htm\">13.6<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&gt;|\u00a0 file<\/td>\n<td width=\"83\">ksh, bash<\/td>\n<td width=\"284\">Output to file , even if noclobber set and file exists.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch13_06.htm\">13.6<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&gt;&amp; file<\/td>\n<td width=\"83\">csh<\/td>\n<td width=\"284\">Redirect standard output and standard error to file .<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch13_05.htm\">13.5<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">m &gt; file<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Redirect output file descriptor m to file .<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_21.htm\">45.21<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">m &gt;&gt; file<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Append output file descriptor m to file .<\/td>\n<td width=\"90\"><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">m &lt; file<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Redirect input file descriptor m from file .<\/td>\n<td width=\"90\"><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&lt;&amp; m<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Take standard input from file descriptor m .<\/td>\n<td width=\"90\"><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&lt;&amp;-<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Close standard input.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_10.htm\">45.10<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&gt;&amp; m<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Use file descriptor m as standard output.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_21.htm\">45.21<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">&gt;&amp;-<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Close standard output.<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_21.htm\">45.21<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">m &lt;&amp; n<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Connect input file descriptor n to file descriptor m .<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_22.htm\">45.22<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">m &lt;&amp;-<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Close input file descriptor m .<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_21.htm\">45.21<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">n &gt;&amp; m<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Connect output file descriptor n to file descriptor m .<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_21.htm\">45.21<\/a><\/td>\n<\/tr>\n<tr>\n<td width=\"99\">m &gt;&amp;-<\/td>\n<td width=\"83\">sh<\/td>\n<td width=\"284\">Close output file descriptor m .<\/td>\n<td width=\"90\"><a href=\"http:\/\/docstore.mik.ua\/orelly\/unix\/upt\/ch45_21.htm\">45.21<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f88\u65e9\u4e4b\u524d\u5728blog\u4e2d\u5c31\u8bb0\u5f55\u8fc7\u4e00\u7bc7\u6587\u7ae0\uff1aLinux Shell\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26\uff0c\u4f46\u89c9\u5f97\u603b\u7ed3\u5f97\u8fd8\u4e0d\u591f\u2014\u2014\u4e0d\u591f\u76f4\u63a5\uff0c\u6240\u4ee5 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,12],"tags":[83,447],"class_list":["post-1838","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-tools","tag-bash","tag-meta-characters"],"views":5176,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=1838"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1838\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=1838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=1838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=1838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}