?? index.html
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><HTML><HEAD><TITLE>Advanced Bash-Scripting Guide</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="NEXT"TITLE="Introduction"HREF="part1.html"><METAHTTP-EQUIV="Content-Style-Type"CONTENT="text/css"><LINKREL="stylesheet"HREF="common/kde-common.css"TYPE="text/css"><METAHTTP-EQUIV="Content-Type"CONTENT="text/html; charset=iso-8859-1"><METAHTTP-EQUIV="Content-Language"CONTENT="en"><LINKREL="stylesheet"HREF="common/kde-localised.css"TYPE="text/css"TITLE="KDE-English"><LINKREL="stylesheet"HREF="common/kde-default.css"TYPE="text/css"TITLE="KDE-Default"></HEAD><BODYCLASS="BOOK"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#AA0000"VLINK="#AA0055"ALINK="#AA0000"STYLE="font-family: sans-serif;"><DIVCLASS="BOOK"><ANAME="AEN1"></A><DIVCLASS="TITLEPAGE"><H1CLASS="TITLE"><ANAME="AEN2">Advanced Bash-Scripting Guide</A></H1><H2CLASS="SUBTITLE">An in-depth exploration of the art of shell scripting</H2>Version <SPANCLASS="RELEASEINFO">5.2<BR></SPAN><PCLASS="PUBDATE">16 March 2008<BR></P><H3CLASS="AUTHOR"><ANAME="AEN5">Mendel Cooper</A></H3><DIVCLASS="AFFILIATION"><SPANCLASS="ORGNAME"><BR></SPAN><DIVCLASS="ADDRESS"><PCLASS="ADDRESS">thegrendel@theriver.com</P></DIV></DIV><DIV><DIVCLASS="ABSTRACT"><ANAME="AEN30"></A><P>This tutorial assumes no previous knowledge of scripting or programming, but progresses rapidly toward an intermediate/advanced level of instruction <SPANCLASS="emphasis"><ICLASS="EMPHASIS">. . . all the while sneaking in little snippets of <SPANCLASS="TRADEMARK">UNIX</SPAN>® wisdom and lore</I></SPAN>. It serves as a textbook, a manual for self-study, and a reference and source of knowledge on shell scripting techniques. The exercises and heavily-commented examples invite active reader participation, under the premise that <TTCLASS="USERINPUT"><B>the only way to really learn scripting is to write scripts</B></TT>.</P><P>This book is suitable for classroom use as a general introduction to programming concepts.</P><P><ANAME="WHERE_TARBALL"></A></P><P><AHREF="http://personal.riverusers.com/~thegrendel/abs-guide-5.2.tar.bz2"TARGET="_top"> The latest update of this document</A>, as an archived, <AHREF="filearchiv.html#BZIPREF">bzip2-ed</A> <SPANCLASS="QUOTE">"tarball"</SPAN> including both the SGML source and rendered HTML, may be downloaded from the author's home site. A <AHREF="http://www.tldp.org/LDP/abs/abs-guide.pdf"TARGET="_top">pdf version</A> is also available (<AHREF="http://personal.riverusers.com/~thegrendel/abs-guide.pdf"TARGET="_top"> pdf mirror site</A>). See the <AHREF="http://personal.riverusers.com/~thegrendel/Change.log"TARGET="_top">change log</A> for a revision history.</P></DIV></DIV><HR></DIV><H1><ANAME="AEN45"></A>Dedication</H1><P>For Anita, the source of all the magic</P><DIVCLASS="TOC"><DL><DT><B>Table of Contents</B></DT><DT>Part 1. <AHREF="part1.html">Introduction</A></DT><DD><DL><DT>1. <AHREF="why-shell.html">Why Shell Programming?</A></DT><DT>2. <AHREF="sha-bang.html">Starting Off With a Sha-Bang</A></DT><DD><DL><DT>2.1. <AHREF="sha-bang.html#INVOKING">Invoking the script</A></DT><DT>2.2. <AHREF="prelimexer.html">Preliminary Exercises</A></DT></DL></DD></DL></DD><DT>Part 2. <AHREF="part2.html">Basics</A></DT><DD><DL><DT>3. <AHREF="special-chars.html">Special Characters</A></DT><DT>4. <AHREF="variables.html">Introduction to Variables and Parameters</A></DT><DD><DL><DT>4.1. <AHREF="variables.html#VARSUBN">Variable Substitution</A></DT><DT>4.2. <AHREF="varassignment.html">Variable Assignment</A></DT><DT>4.3. <AHREF="untyped.html">Bash Variables Are Untyped</A></DT><DT>4.4. <AHREF="othertypesv.html">Special Variable Types</A></DT></DL></DD><DT>5. <AHREF="quoting.html">Quoting</A></DT><DD><DL><DT>5.1. <AHREF="quoting.html#QUOTINGVAR">Quoting Variables</A></DT><DT>5.2. <AHREF="escapingsection.html">Escaping</A></DT></DL></DD><DT>6. <AHREF="exit-status.html">Exit and Exit Status</A></DT><DT>7. <AHREF="tests.html">Tests</A></DT><DD><DL><DT>7.1. <AHREF="tests.html#TESTCONSTRUCTS">Test Constructs</A></DT><DT>7.2. <AHREF="fto.html">File test operators</A></DT><DT>7.3. <AHREF="comparison-ops.html">Other Comparison Operators</A></DT><DT>7.4. <AHREF="nestedifthen.html">Nested <ICLASS="FIRSTTERM">if/then</I> Condition Tests</A></DT><DT>7.5. <AHREF="testtest.html">Testing Your Knowledge of Tests</A></DT></DL></DD><DT>8. <AHREF="operations.html">Operations and Related Topics</A></DT><DD><DL><DT>8.1. <AHREF="operations.html#OPS">Operators</A></DT><DT>8.2. <AHREF="numerical-constants.html">Numerical Constants</A></DT></DL></DD></DL></DD><DT>Part 3. <AHREF="part3.html">Beyond the Basics</A></DT><DD><DL><DT>9. <AHREF="variables2.html">Variables Revisited</A></DT><DD><DL><DT>9.1. <AHREF="variables2.html#INTERNALVARIABLES">Internal Variables</A></DT><DT>9.2. <AHREF="string-manipulation.html">Manipulating Strings</A></DT><DT>9.3. <AHREF="parameter-substitution.html">Parameter Substitution</A></DT><DT>9.4. <AHREF="declareref.html">Typing variables: <BCLASS="COMMAND">declare</B> or <BCLASS="COMMAND">typeset</B></A></DT><DT>9.5. <AHREF="ivr.html">Indirect References</A></DT><DT>9.6. <AHREF="randomvar.html">$RANDOM: generate random integer</A></DT><DT>9.7. <AHREF="dblparens.html">The Double Parentheses Construct</A></DT></DL></DD><DT>10. <AHREF="loops.html">Loops and Branches</A></DT><DD><DL><DT>10.1. <AHREF="loops.html#LOOPS1">Loops</A></DT><DT>10.2. <AHREF="nestedloops.html">Nested Loops</A></DT><DT>10.3. <AHREF="loopcontrol.html">Loop Control</A></DT><DT>10.4. <AHREF="testbranch.html">Testing and Branching</A></DT></DL></DD><DT>11. <AHREF="commandsub.html">Command Substitution</A></DT><DT>12. <AHREF="arithexp.html">Arithmetic Expansion</A></DT><DT>13. <AHREF="recess-time.html">Recess Time</A></DT></DL></DD><DT>Part 4. <AHREF="part4.html">Commands</A></DT><DD><DL><DT>14. <AHREF="internal.html">Internal Commands and Builtins</A></DT><DD><DL><DT>14.1. <AHREF="internal.html#AEN8737">Job Control Commands</A></DT></DL></DD><DT>15. <AHREF="external.html">External Filters, Programs and Commands</A></DT><DD><DL><DT>15.1. <AHREF="external.html#BASIC">Basic Commands</A></DT><DT>15.2. <AHREF="moreadv.html">Complex Commands</A></DT><DT>15.3. <AHREF="timedate.html">Time / Date Commands</A></DT><DT>15.4. <AHREF="textproc.html">Text Processing Commands</A></DT><DT>15.5. <AHREF="filearchiv.html">File and Archiving Commands</A></DT><DT>15.6. <AHREF="communications.html">Communications Commands</A></DT><DT>15.7. <AHREF="terminalccmds.html">Terminal Control Commands</A></DT><DT>15.8. <AHREF="mathc.html">Math Commands</A></DT><DT>15.9. <AHREF="extmisc.html">Miscellaneous Commands</A></DT></DL></DD><DT>16. <AHREF="system.html">System and Administrative Commands</A></DT><DD><DL><DT>16.1. <AHREF="system.html#SYSSCRIPTS">Analyzing a System Script</A></DT></DL></DD></DL></DD><DT>Part 5. <AHREF="part5.html">Advanced Topics</A></DT><DD><DL><DT>17. <AHREF="regexp.html">Regular Expressions</A></DT><DD><DL><DT>17.1. <AHREF="regexp.html#AEN15780">A Brief Introduction to Regular Expressions</A></DT><DT>17.2. <AHREF="globbingref.html">Globbing</A></DT></DL></DD><DT>18. <AHREF="here-docs.html">Here Documents</A></DT><DD><DL><DT>18.1. <AHREF="here-docs.html#AEN16438">Here Strings</A></DT></DL></DD><DT>19. <AHREF="io-redirection.html">I/O Redirection</A></DT><DD><DL><DT>19.1. <AHREF="io-redirection.html#AEN16560">Using <ICLASS="FIRSTTERM">exec</I></A></DT><DT>19.2. <AHREF="redircb.html">Redirecting Code Blocks</A></DT><DT>19.3. <AHREF="redirapps.html">Applications</A></DT></DL></DD><DT>20. <AHREF="subshells.html">Subshells</A></DT><DT>21. <AHREF="restricted-sh.html">Restricted Shells</A></DT><DT>22. <AHREF="process-sub.html">Process Substitution</A></DT><DT>23. <AHREF="functions.html">Functions</A></DT><DD><DL><DT>23.1. <AHREF="functions.html#COMPLEXFUNCT">Complex Functions and Function Complexities</A></DT><DT>23.2. <AHREF="localvar.html">Local Variables</A></DT><DT>23.3. <AHREF="recurnolocvar.html">Recursion Without Local Variables</A></DT></DL></DD><DT>24. <AHREF="aliases.html">Aliases</A></DT><DT>25. <AHREF="list-cons.html">List Constructs</A></DT><DT>26. <AHREF="arrays.html">Arrays</A></DT><DT>27. <AHREF="devproc.html"><TTCLASS="FILENAME">/dev</TT> and <TTCLASS="FILENAME">/proc</TT></A></DT><DD><DL><DT>27.1. <AHREF="devproc.html#DEVREF1"><TTCLASS="FILENAME">/dev</TT></A></DT><DT>27.2. <AHREF="procref1.html"><TTCLASS="FILENAME">/proc</TT></A></DT></DL></DD><DT>28. <AHREF="zeros.html">Of Zeros and Nulls</A></DT><DT>29. <AHREF="debugging.html">Debugging</A></DT><DT>30. <AHREF="options.html">Options</A></DT><DT>31. <AHREF="gotchas.html">Gotchas</A></DT><DT>32. <AHREF="scrstyle.html">Scripting With Style</A></DT><DD><DL><DT>32.1. <AHREF="scrstyle.html#UNOFFICIALST">Unofficial Shell Scripting Stylesheet</A></DT></DL></DD><DT>33. <AHREF="miscellany.html">Miscellany</A></DT><DD><DL><DT>33.1. <AHREF="miscellany.html#INTANDNONINT">Interactive and non-interactive shells and scripts</A></DT><DT>33.2. <AHREF="opprecedence.html">Operator Precedence</A></DT><DT>33.3. <AHREF="wrapper.html">Shell Wrappers</A></DT><DT>33.4. <AHREF="testsandcomparisons.html">Tests and Comparisons: Alternatives</A></DT><DT>33.5. <AHREF="recursionsct.html">A script calling itself (recursion)</A></DT><DT>33.6. <AHREF="colorizing.html"><SPANCLASS="QUOTE">"Colorizing"</SPAN> Scripts</A></DT><DT>33.7. <AHREF="optimizations.html">Optimizations</A></DT><DT>33.8. <AHREF="assortedtips.html">Assorted Tips</A></DT><DT>33.9. <AHREF="securityissues.html">Security Issues</A></DT><DT>33.10. <AHREF="portabilityissues.html">Portability Issues</A></DT><DT>33.11. <AHREF="winscript.html">Shell Scripting Under Windows</A></DT></DL></DD><DT>34. <AHREF="bash2.html">Bash, versions 2 and 3</A></DT><DD><DL><DT>34.1. <AHREF="bash2.html#BASHVER2">Bash, version 2</A></DT><DT>34.2. <AHREF="bashver3.html">Bash, version 3</A></DT></DL></DD></DL></DD><DT>35. <AHREF="endnotes.html">Endnotes</A></DT><DD><DL><DT>35.1. <AHREF="endnotes.html#AUTHORSNOTE">Author's Note</A></DT><DT>35.2. <AHREF="aboutauthor.html">About the Author</A></DT><DT>35.3. <AHREF="wherehelp.html">Where to Go For Help</A></DT><DT>35.4. <AHREF="toolsused.html">Tools Used to Produce This Book</A></DT><DD><DL><DT>35.4.1. <AHREF="toolsused.html#SOFTWARE-HARDWARE">Hardware</A></DT><DT>35.4.2. <AHREF="toolsused.html#SOFTWARE-PRINTWARE">Software and Printware</A></DT></DL></DD><DT>35.5. <AHREF="credits.html">Credits</A></DT><DT>35.6. <AHREF="disclaimer.html">Disclaimer</A></DT></DL></DD><DT><AHREF="biblio.html">Bibliography</A></DT><DT>A. <AHREF="contributed-scripts.html">Contributed Scripts</A></DT><DT>B. <AHREF="refcards.html">Reference Cards</A></DT><DT>C. <AHREF="sedawk.html">A Sed and Awk Micro-Primer</A></DT><DD><DL><DT>C.1. <AHREF="sedawk.html#AEN21068">Sed</A></DT><DT>C.2. <AHREF="awk.html">Awk</A></DT></DL></DD><DT>D. <AHREF="exitcodes.html">Exit Codes With Special Meanings</A></DT><DT>E. <AHREF="ioredirintro.html">A Detailed Introduction to I/O and I/O Redirection</A></DT><DT
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -