UNPKG

esy-bash

Version:

Cross-platform bash utilities - primed for Reason/OCaml

890 lines (846 loc) 774 kB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- This text is a brief description of the features that are present in the Bash shell (version 4.4, 7 September 2016). This is Edition 4.4, last updated 7 September 2016, of The GNU Bash Reference Manual, for Bash, Version 4.4. Copyright (C) 1988-2016 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". --> <!-- Created by GNU Texinfo 6.1, http://www.gnu.org/software/texinfo/ --> <head> <title>Bash Reference Manual</title> <meta name="description" content="Bash Reference Manual"> <meta name="keywords" content="Bash Reference Manual"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="#Top" rel="start" title="Top"> <link href="#Indexes" rel="index" title="Indexes"> <link href="#SEC_Contents" rel="contents" title="Table of Contents"> <link href="dir.html#Top" rel="up" title="(dir)"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} blockquote.smallindentedblock {margin-right: 0em; font-size: smaller} blockquote.smallquotation {font-size: smaller} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} div.lisp {margin-left: 3.2em} div.smalldisplay {margin-left: 3.2em} div.smallexample {margin-left: 3.2em} div.smalllisp {margin-left: 3.2em} kbd {font-style: oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: inherit; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: inherit; font-size: smaller} pre.smalllisp {font-size: smaller} span.nolinebreak {white-space: nowrap} span.roman {font-family: initial; font-weight: normal} span.sansserif {font-family: sans-serif; font-weight: normal} ul.no-bullet {list-style: none} --> </style> </head> <body lang="en"> <h1 class="settitle" align="center">Bash Reference Manual</h1> <a name="SEC_Contents"></a> <h2 class="contents-heading">Table of Contents</h2> <div class="contents"> <ul class="no-bullet"> <li><a name="toc-Introduction-1" href="#Introduction">1 Introduction</a> <ul class="no-bullet"> <li><a name="toc-What-is-Bash_003f-1" href="#What-is-Bash_003f">1.1 What is Bash?</a></li> <li><a name="toc-What-is-a-shell_003f-1" href="#What-is-a-shell_003f">1.2 What is a shell?</a></li> </ul></li> <li><a name="toc-Definitions-1" href="#Definitions">2 Definitions</a></li> <li><a name="toc-Basic-Shell-Features-1" href="#Basic-Shell-Features">3 Basic Shell Features</a> <ul class="no-bullet"> <li><a name="toc-Shell-Syntax-1" href="#Shell-Syntax">3.1 Shell Syntax</a> <ul class="no-bullet"> <li><a name="toc-Shell-Operation-1" href="#Shell-Operation">3.1.1 Shell Operation</a></li> <li><a name="toc-Quoting-1" href="#Quoting">3.1.2 Quoting</a> <ul class="no-bullet"> <li><a name="toc-Escape-Character-1" href="#Escape-Character">3.1.2.1 Escape Character</a></li> <li><a name="toc-Single-Quotes-1" href="#Single-Quotes">3.1.2.2 Single Quotes</a></li> <li><a name="toc-Double-Quotes-1" href="#Double-Quotes">3.1.2.3 Double Quotes</a></li> <li><a name="toc-ANSI_002dC-Quoting-1" href="#ANSI_002dC-Quoting">3.1.2.4 ANSI-C Quoting</a></li> <li><a name="toc-Locale_002dSpecific-Translation" href="#Locale-Translation">3.1.2.5 Locale-Specific Translation</a></li> </ul></li> <li><a name="toc-Comments-1" href="#Comments">3.1.3 Comments</a></li> </ul></li> <li><a name="toc-Shell-Commands-1" href="#Shell-Commands">3.2 Shell Commands</a> <ul class="no-bullet"> <li><a name="toc-Simple-Commands-1" href="#Simple-Commands">3.2.1 Simple Commands</a></li> <li><a name="toc-Pipelines-1" href="#Pipelines">3.2.2 Pipelines</a></li> <li><a name="toc-Lists-of-Commands" href="#Lists">3.2.3 Lists of Commands</a></li> <li><a name="toc-Compound-Commands-1" href="#Compound-Commands">3.2.4 Compound Commands</a> <ul class="no-bullet"> <li><a name="toc-Looping-Constructs-1" href="#Looping-Constructs">3.2.4.1 Looping Constructs</a></li> <li><a name="toc-Conditional-Constructs-1" href="#Conditional-Constructs">3.2.4.2 Conditional Constructs</a></li> <li><a name="toc-Grouping-Commands" href="#Command-Grouping">3.2.4.3 Grouping Commands</a></li> </ul></li> <li><a name="toc-Coprocesses-1" href="#Coprocesses">3.2.5 Coprocesses</a></li> <li><a name="toc-GNU-Parallel-1" href="#GNU-Parallel">3.2.6 GNU Parallel</a></li> </ul></li> <li><a name="toc-Shell-Functions-1" href="#Shell-Functions">3.3 Shell Functions</a></li> <li><a name="toc-Shell-Parameters-1" href="#Shell-Parameters">3.4 Shell Parameters</a> <ul class="no-bullet"> <li><a name="toc-Positional-Parameters-1" href="#Positional-Parameters">3.4.1 Positional Parameters</a></li> <li><a name="toc-Special-Parameters-1" href="#Special-Parameters">3.4.2 Special Parameters</a></li> </ul></li> <li><a name="toc-Shell-Expansions-1" href="#Shell-Expansions">3.5 Shell Expansions</a> <ul class="no-bullet"> <li><a name="toc-Brace-Expansion-1" href="#Brace-Expansion">3.5.1 Brace Expansion</a></li> <li><a name="toc-Tilde-Expansion-1" href="#Tilde-Expansion">3.5.2 Tilde Expansion</a></li> <li><a name="toc-Shell-Parameter-Expansion-1" href="#Shell-Parameter-Expansion">3.5.3 Shell Parameter Expansion</a></li> <li><a name="toc-Command-Substitution-1" href="#Command-Substitution">3.5.4 Command Substitution</a></li> <li><a name="toc-Arithmetic-Expansion-1" href="#Arithmetic-Expansion">3.5.5 Arithmetic Expansion</a></li> <li><a name="toc-Process-Substitution-1" href="#Process-Substitution">3.5.6 Process Substitution</a></li> <li><a name="toc-Word-Splitting-1" href="#Word-Splitting">3.5.7 Word Splitting</a></li> <li><a name="toc-Filename-Expansion-1" href="#Filename-Expansion">3.5.8 Filename Expansion</a> <ul class="no-bullet"> <li><a name="toc-Pattern-Matching-1" href="#Pattern-Matching">3.5.8.1 Pattern Matching</a></li> </ul></li> <li><a name="toc-Quote-Removal-1" href="#Quote-Removal">3.5.9 Quote Removal</a></li> </ul></li> <li><a name="toc-Redirections-1" href="#Redirections">3.6 Redirections</a> <ul class="no-bullet"> <li><a name="toc-Redirecting-Input" href="#Redirecting-Input">3.6.1 Redirecting Input</a></li> <li><a name="toc-Redirecting-Output" href="#Redirecting-Output">3.6.2 Redirecting Output</a></li> <li><a name="toc-Appending-Redirected-Output" href="#Appending-Redirected-Output">3.6.3 Appending Redirected Output</a></li> <li><a name="toc-Redirecting-Standard-Output-and-Standard-Error" href="#Redirecting-Standard-Output-and-Standard-Error">3.6.4 Redirecting Standard Output and Standard Error</a></li> <li><a name="toc-Appending-Standard-Output-and-Standard-Error" href="#Appending-Standard-Output-and-Standard-Error">3.6.5 Appending Standard Output and Standard Error</a></li> <li><a name="toc-Here-Documents" href="#Here-Documents">3.6.6 Here Documents</a></li> <li><a name="toc-Here-Strings" href="#Here-Strings">3.6.7 Here Strings</a></li> <li><a name="toc-Duplicating-File-Descriptors" href="#Duplicating-File-Descriptors">3.6.8 Duplicating File Descriptors</a></li> <li><a name="toc-Moving-File-Descriptors" href="#Moving-File-Descriptors">3.6.9 Moving File Descriptors</a></li> <li><a name="toc-Opening-File-Descriptors-for-Reading-and-Writing" href="#Opening-File-Descriptors-for-Reading-and-Writing">3.6.10 Opening File Descriptors for Reading and Writing</a></li> </ul></li> <li><a name="toc-Executing-Commands-1" href="#Executing-Commands">3.7 Executing Commands</a> <ul class="no-bullet"> <li><a name="toc-Simple-Command-Expansion-1" href="#Simple-Command-Expansion">3.7.1 Simple Command Expansion</a></li> <li><a name="toc-Command-Search-and-Execution-1" href="#Command-Search-and-Execution">3.7.2 Command Search and Execution</a></li> <li><a name="toc-Command-Execution-Environment-1" href="#Command-Execution-Environment">3.7.3 Command Execution Environment</a></li> <li><a name="toc-Environment-1" href="#Environment">3.7.4 Environment</a></li> <li><a name="toc-Exit-Status-1" href="#Exit-Status">3.7.5 Exit Status</a></li> <li><a name="toc-Signals-1" href="#Signals">3.7.6 Signals</a></li> </ul></li> <li><a name="toc-Shell-Scripts-1" href="#Shell-Scripts">3.8 Shell Scripts</a></li> </ul></li> <li><a name="toc-Shell-Builtin-Commands-1" href="#Shell-Builtin-Commands">4 Shell Builtin Commands</a> <ul class="no-bullet"> <li><a name="toc-Bourne-Shell-Builtins-1" href="#Bourne-Shell-Builtins">4.1 Bourne Shell Builtins</a></li> <li><a name="toc-Bash-Builtin-Commands" href="#Bash-Builtins">4.2 Bash Builtin Commands</a></li> <li><a name="toc-Modifying-Shell-Behavior-1" href="#Modifying-Shell-Behavior">4.3 Modifying Shell Behavior</a> <ul class="no-bullet"> <li><a name="toc-The-Set-Builtin-1" href="#The-Set-Builtin">4.3.1 The Set Builtin</a></li> <li><a name="toc-The-Shopt-Builtin-1" href="#The-Shopt-Builtin">4.3.2 The Shopt Builtin</a></li> </ul></li> <li><a name="toc-Special-Builtins-1" href="#Special-Builtins">4.4 Special Builtins</a></li> </ul></li> <li><a name="toc-Shell-Variables-1" href="#Shell-Variables">5 Shell Variables</a> <ul class="no-bullet"> <li><a name="toc-Bourne-Shell-Variables-1" href="#Bourne-Shell-Variables">5.1 Bourne Shell Variables</a></li> <li><a name="toc-Bash-Variables-1" href="#Bash-Variables">5.2 Bash Variables</a></li> </ul></li> <li><a name="toc-Bash-Features-2" href="#Bash-Features">6 Bash Features</a> <ul class="no-bullet"> <li><a name="toc-Invoking-Bash-1" href="#Invoking-Bash">6.1 Invoking Bash</a></li> <li><a name="toc-Bash-Startup-Files-1" href="#Bash-Startup-Files">6.2 Bash Startup Files</a></li> <li><a name="toc-Interactive-Shells-1" href="#Interactive-Shells">6.3 Interactive Shells</a> <ul class="no-bullet"> <li><a name="toc-What-is-an-Interactive-Shell_003f-1" href="#What-is-an-Interactive-Shell_003f">6.3.1 What is an Interactive Shell?</a></li> <li><a name="toc-Is-this-Shell-Interactive_003f-1" href="#Is-this-Shell-Interactive_003f">6.3.2 Is this Shell Interactive?</a></li> <li><a name="toc-Interactive-Shell-Behavior-1" href="#Interactive-Shell-Behavior">6.3.3 Interactive Shell Behavior</a></li> </ul></li> <li><a name="toc-Bash-Conditional-Expressions-1" href="#Bash-Conditional-Expressions">6.4 Bash Conditional Expressions</a></li> <li><a name="toc-Shell-Arithmetic-1" href="#Shell-Arithmetic">6.5 Shell Arithmetic</a></li> <li><a name="toc-Aliases-1" href="#Aliases">6.6 Aliases</a></li> <li><a name="toc-Arrays-1" href="#Arrays">6.7 Arrays</a></li> <li><a name="toc-The-Directory-Stack-1" href="#The-Directory-Stack">6.8 The Directory Stack</a> <ul class="no-bullet"> <li><a name="toc-Directory-Stack-Builtins-1" href="#Directory-Stack-Builtins">6.8.1 Directory Stack Builtins</a></li> </ul></li> <li><a name="toc-Controlling-the-Prompt-1" href="#Controlling-the-Prompt">6.9 Controlling the Prompt</a></li> <li><a name="toc-The-Restricted-Shell-1" href="#The-Restricted-Shell">6.10 The Restricted Shell</a></li> <li><a name="toc-Bash-POSIX-Mode-1" href="#Bash-POSIX-Mode">6.11 Bash POSIX Mode</a></li> </ul></li> <li><a name="toc-Job-Control-1" href="#Job-Control">7 Job Control</a> <ul class="no-bullet"> <li><a name="toc-Job-Control-Basics-1" href="#Job-Control-Basics">7.1 Job Control Basics</a></li> <li><a name="toc-Job-Control-Builtins-1" href="#Job-Control-Builtins">7.2 Job Control Builtins</a></li> <li><a name="toc-Job-Control-Variables-1" href="#Job-Control-Variables">7.3 Job Control Variables</a></li> </ul></li> <li><a name="toc-Command-Line-Editing-1" href="#Command-Line-Editing">8 Command Line Editing</a> <ul class="no-bullet"> <li><a name="toc-Introduction-to-Line-Editing" href="#Introduction-and-Notation">8.1 Introduction to Line Editing</a></li> <li><a name="toc-Readline-Interaction-1" href="#Readline-Interaction">8.2 Readline Interaction</a> <ul class="no-bullet"> <li><a name="toc-Readline-Bare-Essentials-1" href="#Readline-Bare-Essentials">8.2.1 Readline Bare Essentials</a></li> <li><a name="toc-Readline-Movement-Commands-1" href="#Readline-Movement-Commands">8.2.2 Readline Movement Commands</a></li> <li><a name="toc-Readline-Killing-Commands-1" href="#Readline-Killing-Commands">8.2.3 Readline Killing Commands</a></li> <li><a name="toc-Readline-Arguments-1" href="#Readline-Arguments">8.2.4 Readline Arguments</a></li> <li><a name="toc-Searching-for-Commands-in-the-History" href="#Searching">8.2.5 Searching for Commands in the History</a></li> </ul></li> <li><a name="toc-Readline-Init-File-1" href="#Readline-Init-File">8.3 Readline Init File</a> <ul class="no-bullet"> <li><a name="toc-Readline-Init-File-Syntax-1" href="#Readline-Init-File-Syntax">8.3.1 Readline Init File Syntax</a></li> <li><a name="toc-Conditional-Init-Constructs-1" href="#Conditional-Init-Constructs">8.3.2 Conditional Init Constructs</a></li> <li><a name="toc-Sample-Init-File-1" href="#Sample-Init-File">8.3.3 Sample Init File</a></li> </ul></li> <li><a name="toc-Bindable-Readline-Commands-1" href="#Bindable-Readline-Commands">8.4 Bindable Readline Commands</a> <ul class="no-bullet"> <li><a name="toc-Commands-For-Moving-1" href="#Commands-For-Moving">8.4.1 Commands For Moving</a></li> <li><a name="toc-Commands-For-Manipulating-The-History" href="#Commands-For-History">8.4.2 Commands For Manipulating The History</a></li> <li><a name="toc-Commands-For-Changing-Text" href="#Commands-For-Text">8.4.3 Commands For Changing Text</a></li> <li><a name="toc-Killing-And-Yanking" href="#Commands-For-Killing">8.4.4 Killing And Yanking</a></li> <li><a name="toc-Specifying-Numeric-Arguments" href="#Numeric-Arguments">8.4.5 Specifying Numeric Arguments</a></li> <li><a name="toc-Letting-Readline-Type-For-You" href="#Commands-For-Completion">8.4.6 Letting Readline Type For You</a></li> <li><a name="toc-Keyboard-Macros-1" href="#Keyboard-Macros">8.4.7 Keyboard Macros</a></li> <li><a name="toc-Some-Miscellaneous-Commands" href="#Miscellaneous-Commands">8.4.8 Some Miscellaneous Commands</a></li> </ul></li> <li><a name="toc-Readline-vi-Mode-1" href="#Readline-vi-Mode">8.5 Readline vi Mode</a></li> <li><a name="toc-Programmable-Completion-1" href="#Programmable-Completion">8.6 Programmable Completion</a></li> <li><a name="toc-Programmable-Completion-Builtins-1" href="#Programmable-Completion-Builtins">8.7 Programmable Completion Builtins</a></li> <li><a name="toc-A-Programmable-Completion-Example-1" href="#A-Programmable-Completion-Example">8.8 A Programmable Completion Example</a></li> </ul></li> <li><a name="toc-Using-History-Interactively-1" href="#Using-History-Interactively">9 Using History Interactively</a> <ul class="no-bullet"> <li><a name="toc-Bash-History-Facilities-1" href="#Bash-History-Facilities">9.1 Bash History Facilities</a></li> <li><a name="toc-Bash-History-Builtins-1" href="#Bash-History-Builtins">9.2 Bash History Builtins</a></li> <li><a name="toc-History-Expansion" href="#History-Interaction">9.3 History Expansion</a> <ul class="no-bullet"> <li><a name="toc-Event-Designators-1" href="#Event-Designators">9.3.1 Event Designators</a></li> <li><a name="toc-Word-Designators-1" href="#Word-Designators">9.3.2 Word Designators</a></li> <li><a name="toc-Modifiers-1" href="#Modifiers">9.3.3 Modifiers</a></li> </ul></li> </ul></li> <li><a name="toc-Installing-Bash-1" href="#Installing-Bash">10 Installing Bash</a> <ul class="no-bullet"> <li><a name="toc-Basic-Installation-1" href="#Basic-Installation">10.1 Basic Installation</a></li> <li><a name="toc-Compilers-and-Options-1" href="#Compilers-and-Options">10.2 Compilers and Options</a></li> <li><a name="toc-Compiling-For-Multiple-Architectures-1" href="#Compiling-For-Multiple-Architectures">10.3 Compiling For Multiple Architectures</a></li> <li><a name="toc-Installation-Names-1" href="#Installation-Names">10.4 Installation Names</a></li> <li><a name="toc-Specifying-the-System-Type-1" href="#Specifying-the-System-Type">10.5 Specifying the System Type</a></li> <li><a name="toc-Sharing-Defaults-1" href="#Sharing-Defaults">10.6 Sharing Defaults</a></li> <li><a name="toc-Operation-Controls-1" href="#Operation-Controls">10.7 Operation Controls</a></li> <li><a name="toc-Optional-Features-1" href="#Optional-Features">10.8 Optional Features</a></li> </ul></li> <li><a name="toc-Reporting-Bugs-1" href="#Reporting-Bugs">Appendix A Reporting Bugs</a></li> <li><a name="toc-Major-Differences-From-The-Bourne-Shell-1" href="#Major-Differences-From-The-Bourne-Shell">Appendix B Major Differences From The Bourne Shell</a> <ul class="no-bullet"> <li><a name="toc-Implementation-Differences-From-The-SVR4_002e2-Shell" href="#Implementation-Differences-From-The-SVR4_002e2-Shell">B.1 Implementation Differences From The SVR4.2 Shell</a></li> </ul></li> <li><a name="toc-GNU-Free-Documentation-License-1" href="#GNU-Free-Documentation-License">Appendix C GNU Free Documentation License</a></li> <li><a name="toc-Indexes-1" href="#Indexes">Appendix D Indexes</a> <ul class="no-bullet"> <li><a name="toc-Index-of-Shell-Builtin-Commands" href="#Builtin-Index">D.1 Index of Shell Builtin Commands</a></li> <li><a name="toc-Index-of-Shell-Reserved-Words" href="#Reserved-Word-Index">D.2 Index of Shell Reserved Words</a></li> <li><a name="toc-Parameter-and-Variable-Index" href="#Variable-Index">D.3 Parameter and Variable Index</a></li> <li><a name="toc-Function-Index-1" href="#Function-Index">D.4 Function Index</a></li> <li><a name="toc-Concept-Index-1" href="#Concept-Index">D.5 Concept Index</a></li> </ul></li> </ul> </div> <a name="Top"></a> <div class="header"> <p> Next: <a href="#Introduction" accesskey="n" rel="next">Introduction</a>, Previous: <a href="dir.html#Top" accesskey="p" rel="prev">(dir)</a>, Up: <a href="dir.html#Top" accesskey="u" rel="up">(dir)</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="Bash-Features-1"></a> <h1 class="top">Bash Features</h1> <p>This text is a brief description of the features that are present in the Bash shell (version 4.4, 7 September 2016). The Bash home page is <a href="http://www.gnu.org/software/bash/">http://www.gnu.org/software/bash/</a>. </p> <p>This is Edition 4.4, last updated 7 September 2016, of <cite>The GNU Bash Reference Manual</cite>, for <code>Bash</code>, Version 4.4. </p> <p>Bash contains features that appear in other popular shells, and some features that only appear in Bash. Some of the shells that Bash has borrowed concepts from are the Bourne Shell (<samp>sh</samp>), the Korn Shell (<samp>ksh</samp>), and the C-shell (<samp>csh</samp> and its successor, <samp>tcsh</samp>). The following menu breaks the features up into categories, noting which features were inspired by other shells and which are specific to Bash. </p> <p>This manual is meant as a brief introduction to features found in Bash. The Bash manual page should be used as the definitive reference on shell behavior. </p> <table class="menu" border="0" cellspacing="0"> <tr><td align="left" valign="top">&bull; <a href="#Introduction" accesskey="1">Introduction</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">An introduction to the shell. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Definitions" accesskey="2">Definitions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Some definitions used in the rest of this manual. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Basic-Shell-Features" accesskey="3">Basic Shell Features</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The shell &quot;building blocks&quot;. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Shell-Builtin-Commands" accesskey="4">Shell Builtin Commands</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Commands that are a part of the shell. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Shell-Variables" accesskey="5">Shell Variables</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Variables used or set by Bash. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Bash-Features" accesskey="6">Bash Features</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Features found only in Bash. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Job-Control" accesskey="7">Job Control</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">What job control is and how Bash allows you to use it. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Command-Line-Editing" accesskey="8">Command Line Editing</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Chapter describing the command line editing features. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Using-History-Interactively" accesskey="9">Using History Interactively</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Command History Expansion </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Installing-Bash">Installing Bash</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to build and install Bash on your system. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Reporting-Bugs">Reporting Bugs</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to report bugs in Bash. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Major-Differences-From-The-Bourne-Shell">Major Differences From The Bourne Shell</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A terse list of the differences between Bash and historical versions of /bin/sh. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Copying and sharing this documentation. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Indexes">Indexes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Various indexes for this manual. </td></tr> </table> <hr> <a name="Introduction"></a> <div class="header"> <p> Next: <a href="#Definitions" accesskey="n" rel="next">Definitions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="Introduction-1"></a> <h2 class="chapter">1 Introduction</h2> <table class="menu" border="0" cellspacing="0"> <tr><td align="left" valign="top">&bull; <a href="#What-is-Bash_003f" accesskey="1">What is Bash?</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A short description of Bash. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#What-is-a-shell_003f" accesskey="2">What is a shell?</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">A brief introduction to shells. </td></tr> </table> <hr> <a name="What-is-Bash_003f"></a> <div class="header"> <p> Next: <a href="#What-is-a-shell_003f" accesskey="n" rel="next">What is a shell?</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="What-is-Bash_003f-1"></a> <h3 class="section">1.1 What is Bash?</h3> <p>Bash is the shell, or command language interpreter, for the <small>GNU</small> operating system. The name is an acronym for the &lsquo;<samp>Bourne-Again SHell</samp>&rsquo;, a pun on Stephen Bourne, the author of the direct ancestor of the current Unix shell <code>sh</code>, which appeared in the Seventh Edition Bell Labs Research version of Unix. </p> <p>Bash is largely compatible with <code>sh</code> and incorporates useful features from the Korn shell <code>ksh</code> and the C shell <code>csh</code>. It is intended to be a conformant implementation of the <small>IEEE</small> <small>POSIX</small> Shell and Tools portion of the <small>IEEE</small> <small>POSIX</small> specification (<small>IEEE</small> Standard 1003.1). It offers functional improvements over <code>sh</code> for both interactive and programming use. </p> <p>While the <small>GNU</small> operating system provides other shells, including a version of <code>csh</code>, Bash is the default shell. Like other <small>GNU</small> software, Bash is quite portable. It currently runs on nearly every version of Unix and a few other operating systems - independently-supported ports exist for <small>MS-DOS</small>, <small>OS/2</small>, and Windows platforms. </p> <hr> <a name="What-is-a-shell_003f"></a> <div class="header"> <p> Previous: <a href="#What-is-Bash_003f" accesskey="p" rel="prev">What is Bash?</a>, Up: <a href="#Introduction" accesskey="u" rel="up">Introduction</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="What-is-a-shell_003f-1"></a> <h3 class="section">1.2 What is a shell?</h3> <p>At its base, a shell is simply a macro processor that executes commands. The term macro processor means functionality where text and symbols are expanded to create larger expressions. </p> <p>A Unix shell is both a command interpreter and a programming language. As a command interpreter, the shell provides the user interface to the rich set of <small>GNU</small> utilities. The programming language features allow these utilities to be combined. Files containing commands can be created, and become commands themselves. These new commands have the same status as system commands in directories such as <samp>/bin</samp>, allowing users or groups to establish custom environments to automate their common tasks. </p> <p>Shells may be used interactively or non-interactively. In interactive mode, they accept input typed from the keyboard. When executing non-interactively, shells execute commands read from a file. </p> <p>A shell allows execution of <small>GNU</small> commands, both synchronously and asynchronously. The shell waits for synchronous commands to complete before accepting more input; asynchronous commands continue to execute in parallel with the shell while it reads and executes additional commands. The <em>redirection</em> constructs permit fine-grained control of the input and output of those commands. Moreover, the shell allows control over the contents of commands&rsquo; environments. </p> <p>Shells also provide a small set of built-in commands (<em>builtins</em>) implementing functionality impossible or inconvenient to obtain via separate utilities. For example, <code>cd</code>, <code>break</code>, <code>continue</code>, and <code>exec</code> cannot be implemented outside of the shell because they directly manipulate the shell itself. The <code>history</code>, <code>getopts</code>, <code>kill</code>, or <code>pwd</code> builtins, among others, could be implemented in separate utilities, but they are more convenient to use as builtin commands. All of the shell builtins are described in subsequent sections. </p> <p>While executing commands is essential, most of the power (and complexity) of shells is due to their embedded programming languages. Like any high-level language, the shell provides variables, flow control constructs, quoting, and functions. </p> <p>Shells offer features geared specifically for interactive use rather than to augment the programming language. These interactive features include job control, command line editing, command history and aliases. Each of these features is described in this manual. </p> <hr> <a name="Definitions"></a> <div class="header"> <p> Next: <a href="#Basic-Shell-Features" accesskey="n" rel="next">Basic Shell Features</a>, Previous: <a href="#Introduction" accesskey="p" rel="prev">Introduction</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="Definitions-1"></a> <h2 class="chapter">2 Definitions</h2> <p>These definitions are used throughout the remainder of this manual. </p> <dl compact="compact"> <dt><code>POSIX</code></dt> <dd><a name="index-POSIX"></a> <p>A family of open system standards based on Unix. Bash is primarily concerned with the Shell and Utilities portion of the <small>POSIX</small> 1003.1 standard. </p> </dd> <dt><code>blank</code></dt> <dd><p>A space or tab character. </p> </dd> <dt><code>builtin</code></dt> <dd><a name="index-builtin-1"></a> <p>A command that is implemented internally by the shell itself, rather than by an executable program somewhere in the file system. </p> </dd> <dt><code>control operator</code></dt> <dd><a name="index-control-operator"></a> <p>A <code>token</code> that performs a control function. It is a <code>newline</code> or one of the following: &lsquo;<samp>||</samp>&rsquo;, &lsquo;<samp>&amp;&amp;</samp>&rsquo;, &lsquo;<samp>&amp;</samp>&rsquo;, &lsquo;<samp>;</samp>&rsquo;, &lsquo;<samp>;;</samp>&rsquo;, &lsquo;<samp>;&amp;</samp>&rsquo;, &lsquo;<samp>;;&amp;</samp>&rsquo;, &lsquo;<samp>|</samp>&rsquo;, &lsquo;<samp>|&amp;</samp>&rsquo;, &lsquo;<samp>(</samp>&rsquo;, or &lsquo;<samp>)</samp>&rsquo;. </p> </dd> <dt><code>exit status</code></dt> <dd><a name="index-exit-status"></a> <p>The value returned by a command to its caller. The value is restricted to eight bits, so the maximum value is 255. </p> </dd> <dt><code>field</code></dt> <dd><a name="index-field"></a> <p>A unit of text that is the result of one of the shell expansions. After expansion, when executing a command, the resulting fields are used as the command name and arguments. </p> </dd> <dt><code>filename</code></dt> <dd><a name="index-filename"></a> <p>A string of characters used to identify a file. </p> </dd> <dt><code>job</code></dt> <dd><a name="index-job"></a> <p>A set of processes comprising a pipeline, and any processes descended from it, that are all in the same process group. </p> </dd> <dt><code>job control</code></dt> <dd><a name="index-job-control"></a> <p>A mechanism by which users can selectively stop (suspend) and restart (resume) execution of processes. </p> </dd> <dt><code>metacharacter</code></dt> <dd><a name="index-metacharacter"></a> <p>A character that, when unquoted, separates words. A metacharacter is a <code>space</code>, <code>tab</code>, <code>newline</code>, or one of the following characters: &lsquo;<samp>|</samp>&rsquo;, &lsquo;<samp>&amp;</samp>&rsquo;, &lsquo;<samp>;</samp>&rsquo;, &lsquo;<samp>(</samp>&rsquo;, &lsquo;<samp>)</samp>&rsquo;, &lsquo;<samp>&lt;</samp>&rsquo;, or &lsquo;<samp>&gt;</samp>&rsquo;. </p> </dd> <dt><code>name</code></dt> <dd><a name="index-name"></a> <a name="index-identifier"></a> <p>A <code>word</code> consisting solely of letters, numbers, and underscores, and beginning with a letter or underscore. <code>Name</code>s are used as shell variable and function names. Also referred to as an <code>identifier</code>. </p> </dd> <dt><code>operator</code></dt> <dd><a name="index-operator_002c-shell"></a> <p>A <code>control operator</code> or a <code>redirection operator</code>. See <a href="#Redirections">Redirections</a>, for a list of redirection operators. Operators contain at least one unquoted <code>metacharacter</code>. </p> </dd> <dt><code>process group</code></dt> <dd><a name="index-process-group"></a> <p>A collection of related processes each having the same process group <small>ID</small>. </p> </dd> <dt><code>process group ID</code></dt> <dd><a name="index-process-group-ID"></a> <p>A unique identifier that represents a <code>process group</code> during its lifetime. </p> </dd> <dt><code>reserved word</code></dt> <dd><a name="index-reserved-word"></a> <p>A <code>word</code> that has a special meaning to the shell. Most reserved words introduce shell flow control constructs, such as <code>for</code> and <code>while</code>. </p> </dd> <dt><code>return status</code></dt> <dd><a name="index-return-status"></a> <p>A synonym for <code>exit status</code>. </p> </dd> <dt><code>signal</code></dt> <dd><a name="index-signal"></a> <p>A mechanism by which a process may be notified by the kernel of an event occurring in the system. </p> </dd> <dt><code>special builtin</code></dt> <dd><a name="index-special-builtin"></a> <p>A shell builtin command that has been classified as special by the <small>POSIX</small> standard. </p> </dd> <dt><code>token</code></dt> <dd><a name="index-token"></a> <p>A sequence of characters considered a single unit by the shell. It is either a <code>word</code> or an <code>operator</code>. </p> </dd> <dt><code>word</code></dt> <dd><a name="index-word"></a> <p>A sequence of characters treated as a unit by the shell. Words may not include unquoted <code>metacharacters</code>. </p></dd> </dl> <hr> <a name="Basic-Shell-Features"></a> <div class="header"> <p> Next: <a href="#Shell-Builtin-Commands" accesskey="n" rel="next">Shell Builtin Commands</a>, Previous: <a href="#Definitions" accesskey="p" rel="prev">Definitions</a>, Up: <a href="#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="Basic-Shell-Features-1"></a> <h2 class="chapter">3 Basic Shell Features</h2> <a name="index-Bourne-shell"></a> <p>Bash is an acronym for &lsquo;<samp>Bourne-Again SHell</samp>&rsquo;. The Bourne shell is the traditional Unix shell originally written by Stephen Bourne. All of the Bourne shell builtin commands are available in Bash, The rules for evaluation and quoting are taken from the <small>POSIX</small> specification for the &lsquo;standard&rsquo; Unix shell. </p> <p>This chapter briefly summarizes the shell&rsquo;s &lsquo;building blocks&rsquo;: commands, control structures, shell functions, shell <i>parameters</i>, shell expansions, <i>redirections</i>, which are a way to direct input and output from and to named files, and how the shell executes commands. </p> <table class="menu" border="0" cellspacing="0"> <tr><td align="left" valign="top">&bull; <a href="#Shell-Syntax" accesskey="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">&bull; <a href="#Shell-Commands" accesskey="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">&bull; <a href="#Shell-Functions" accesskey="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">&bull; <a href="#Shell-Parameters" accesskey="4">Shell Parameters</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How the shell stores values. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Shell-Expansions" accesskey="5">Shell Expansions</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How Bash expands parameters and the various expansions available. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Redirections" accesskey="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">&bull; <a href="#Executing-Commands" accesskey="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">&bull; <a href="#Shell-Scripts" accesskey="8">Shell Scripts</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Executing files of shell commands. </td></tr> </table> <hr> <a name="Shell-Syntax"></a> <div class="header"> <p> Next: <a href="#Shell-Commands" accesskey="n" rel="next">Shell Commands</a>, Up: <a href="#Basic-Shell-Features" accesskey="u" rel="up">Basic Shell Features</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="Shell-Syntax-1"></a> <h3 class="section">3.1 Shell Syntax</h3> <table class="menu" border="0" cellspacing="0"> <tr><td align="left" valign="top">&bull; <a href="#Shell-Operation" accesskey="1">Shell Operation</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">The basic operation of the shell. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Quoting" accesskey="2">Quoting</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to remove the special meaning from characters. </td></tr> <tr><td align="left" valign="top">&bull; <a href="#Comments" accesskey="3">Comments</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to specify comments. </td></tr> </table> <p>When the shell reads input, it proceeds through a sequence of operations. If the input indicates the beginning of a comment, the shell ignores the comment symbol (&lsquo;<samp>#</samp>&rsquo;), and the rest of that line. </p> <p>Otherwise, roughly speaking, the shell reads its input and divides the input into words and operators, employing the quoting rules to 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, expands others, redirects input and output as needed, executes the specified command, waits for the command&rsquo;s exit status, and makes that exit status available for further inspection or processing. </p> <hr> <a name="Shell-Operation"></a> <div class="header"> <p> Next: <a href="#Quoting" accesskey="n" rel="next">Quoting</a>, Up: <a href="#Shell-Syntax" accesskey="u" rel="up">Shell Syntax</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="Shell-Operation-1"></a> <h4 class="subsection">3.1.1 Shell Operation</h4> <p>The following is a brief description of the shell&rsquo;s operation when it reads and executes a command. Basically, the shell does the following: </p> <ol> <li> Reads its input from a file (see <a href="#Shell-Scripts">Shell Scripts</a>), from a string supplied as an argument to the <samp>-c</samp> invocation option (see <a href="#Invoking-Bash">Invoking Bash</a>), or from the user&rsquo;s terminal. </li><li> Breaks the input into words and operators, obeying the quoting rules described in <a href="#Quoting">Quoting</a>. These tokens are separated by <code>metacharacters</code>. Alias expansion is performed by this step (see <a href="#Aliases">Aliases</a>). </li><li> Parses the tokens into simple and compound commands (see <a href="#Shell-Commands">Shell Commands</a>). </li><li> Performs the various shell expansions (see <a href="#Shell-Expansions">Shell Expansions</a>), breaking the expanded tokens into lists of filenames (see <a href="#Filename-Expansion">Filename Expansion</a>) and commands and arguments. </li><li> Performs any necessary redirections (see <a href="#Redirections">Redirections</a>) and removes the redirection operators and their operands from the argument list. </li><li> Executes the command (see <a href="#Executing-Commands">Executing Commands</a>). </li><li> Optionally waits for the command to complete and collects its exit status (see <a href="#Exit-Status">Exit Status</a>). </li></ol> <hr> <a name="Quoting"></a> <div class="header"> <p> Next: <a href="#Comments" accesskey="n" rel="next">Comments</a>, Previous: <a href="#Shell-Operation" accesskey="p" rel="prev">Shell Operation</a>, Up: <a href="#Shell-Syntax" accesskey="u" rel="up">Shell Syntax</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="Quoting-1"></a> <h4 class="subsection">3.1.2 Quoting</h4> <a name="index-quoting"></a> <table class="menu" border="0" cellspacing="0"> <tr><td align="left" valign="top">&bull; <a href="#Escape-Character" accesskey="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">&bull; <a href="#Single-Quotes" accesskey="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">&bull; <a href="#Double-Quotes" accesskey="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">&bull; <a href="#ANSI_002dC-Quoting" accesskey="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> <tr><td align="left" valign="top">&bull; <a href="#Locale-Translation" accesskey="5">Locale Translation</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">How to translate strings into different languages. </td></tr> </table> <p>Quoting is used to remove the special meaning of certain characters or words to the shell. Quoting can be used to disable special treatment for special characters, to prevent reserved words from being recognized as such, and to prevent parameter expansion. </p> <p>Each of the shell metacharacters (see <a href="#Definitions">Definitions</a>) has special meaning to the shell and must be quoted if it is to represent itself. When the command history expansion facilities are being used (see <a href="#History-Interaction">History Interaction</a>), the <var>history expansion</var> character, usually &lsquo;<samp>!</samp>&rsquo;, must be quoted to prevent history expansion. See <a href="#Bash-History-Facilities">Bash History Facilities</a>, for more details concerning history expansion. </p> <p>There are three quoting mechanisms: the <var>escape character</var>, single quotes, and double quotes. </p> <hr> <a name="Escape-Character"></a> <div class="header"> <p> Next: <a href="#Single-Quotes" accesskey="n" rel="next">Single Quotes</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="Escape-Character-1"></a> <h4 class="subsubsection">3.1.2.1 Escape Character</h4> <p>A non-quoted backslash &lsquo;<samp>\</samp>&rsquo; 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> pair appears, and the backslash itself is not quoted, the <code>\newline</code> is treated as a line continuation (that is, it is removed from the input stream and effectively ignored). </p> <hr> <a name="Single-Quotes"></a> <div class="header"> <p> Next: <a href="#Double-Quotes" accesskey="n" rel="next">Double Quotes</a>, Previous: <a href="#Escape-Character" accesskey="p" rel="prev">Escape Character</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="Single-Quotes-1"></a> <h4 class="subsubsection">3.1.2.2 Single Quotes</h4> <p>Enclosing characters in single quotes (&lsquo;<samp>'</samp>&rsquo;) preserves the literal value of each character within the quotes. A single quote may not occur between single quotes, even when preceded by a backslash. </p> <hr> <a name="Double-Quotes"></a> <div class="header"> <p> Next: <a href="#ANSI_002dC-Quoting" accesskey="n" rel="next">ANSI-C Quoting</a>, Previous: <a href="#Single-Quotes" accesskey="p" rel="prev">Single Quotes</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="Double-Quotes-1"></a> <h4 class="subsubsection">3.1.2.3 Double Quotes</h4> <p>Enclosing characters in double quotes (&lsquo;<samp>&quot;</samp>&rsquo;) preserves the literal value of all characters within the quotes, with the exception of &lsquo;<samp>$</samp>&rsquo;, &lsquo;<samp>`</samp>&rsquo;, &lsquo;<samp>\</samp>&rsquo;, and, when history expansion is enabled, &lsquo;<samp>!</samp>&rsquo;. When the shell is in <small>POSIX</small> mode (see <a href="#Bash-POSIX-Mode">Bash POSIX Mode</a>), the &lsquo;<samp>!</samp>&rsquo; has no special meaning within double quotes, even when history expansion is enabled. The characters &lsquo;<samp>$</samp>&rsquo; and &lsquo;<samp>`</samp>&rsquo; retain their special meaning within double quotes (see <a href="#Shell-Expansions">Shell Expansions</a>). The backslash retains its special meaning only when followed by one of the following characters: &lsquo;<samp>$</samp>&rsquo;, &lsquo;<samp>`</samp>&rsquo;, &lsquo;<samp>&quot;</samp>&rsquo;, &lsquo;<samp>\</samp>&rsquo;, or <code>newline</code>. Within double quotes, backslashes that are followed by one of these characters are removed. Backslashes preceding characters without a special meaning are left unmodified. A double quote may be quoted within double quotes by preceding it with a backslash. If enabled, history expansion will be performed unless an &lsquo;<samp>!</samp>&rsquo; appearing in double quotes is escaped using a backslash. The backslash preceding the &lsquo;<samp>!</samp>&rsquo; is not removed. </p> <p>The special parameters &lsquo;<samp>*</samp>&rsquo; and &lsquo;<samp>@</samp>&rsquo; have special meaning when in double quotes (see <a href="#Shell-Parameter-Expansion">Shell Parameter Expansion</a>). </p> <hr> <a name="ANSI_002dC-Quoting"></a> <div class="header"> <p> Next: <a href="#Locale-Translation" accesskey="n" rel="next">Locale Translation</a>, Previous: <a href="#Double-Quotes" accesskey="p" rel="prev">Double Quotes</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="#Indexes" title="Index" rel="index">Index</a>]</p> </div> <a name="ANSI_002dC-Quoting-1"></a> <h4 class="subsubsection">3.1.2.4 ANSI-C Quoting</h4> <a name="index-quoting_002c-ANSI"></a> <p>Words of the form <code>$'<var>string</var>'</code> are treated specially. The word expands to <var>string</var>, with backslash-escaped characters replaced as specified by the ANSI C standard. Backslash escape sequences, if present, are decoded as follows: </p> <dl compact="compact"> <dt><code>\a</code></dt> <dd><p>alert (bell) </p></dd> <dt><code>\b</code></dt> <dd><p>backspace </p></dd> <dt><code>\e</code></dt> <dt><code>\E</code></dt> <dd><p>an escape character (not ANSI C) </p></dd> <dt><code>\f</code></dt> <dd><p>form feed </p></dd> <dt><code>\n</code></dt> <dd><p>newline </p></dd> <dt><code>\r</code></dt> <dd><p>carriage return </p></dd> <dt><code>\t</code></dt> <dd><p>horizontal tab </p></dd> <dt><code>\v</code></dt> <dd><p>vertical tab </p></dd> <dt><code>\\</code></dt> <dd><p>backslash </p></dd> <dt><code>\'</code></dt> <dd><p>single quote </p></dd> <dt><code>\&quot;</code></dt> <dd><p>double quote </p></dd> <dt><code>\?</code></dt> <dd><p>question mark </p></dd> <dt><code>\<var>nnn</var></code></dt> <dd><p>the eight-bit character whose value is the octal value <var>nnn</var> (one to three digits) </p></dd> <dt><code>\x<var>HH</var></code></dt> <dd><p>the eight-bit character whose value is the hexadecimal value <var>HH</var> (one or two hex digits) </p></dd> <dt><code>\u<var>HHHH</var></code></dt> <dd><p>the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value <var>HHHH</var> (one to four hex digits) </p></dd> <dt><code>\U<var>HHHHHHHH</var></code></dt> <dd><p>the Unicode (ISO/IEC 10646) character whose value is the hexadecimal value <var>HHHHHHHH</var> (one to eight hex digits) </p></dd> <dt><code>\c<var>x</var></code></dt> <dd><p>a control-<var>x</var> character </p></dd> </dl> <p>The expanded result is single-quoted, as if the dollar sign had not been present. </p> <hr> <a name="Locale-Translation"></a> <div class="header"> <p> Previous: <a href="#ANSI_002dC-Quoting" accesskey="p" rel="prev">ANSI-C Quoting</a>, Up: <a href="#Quoting" accesskey="u" rel="up">Quoting</a> &nbsp; [<a href="#SEC_Contents" title="Table of contents" rel="contents">Co