📄 bashref.texi
字号:
\input texinfo.tex @c -*- texinfo -*-@c %**start of header@setfilename bashref.info@settitle Bash Reference Manual@c %**end of header@setchapternewpage odd@include version.texi@copyingThis text is a brief description of the features that are present inthe Bash shell (version @value{VERSION}, @value{UPDATED}).This is Edition @value{EDITION}, last updated @value{UPDATED},of @cite{The GNU Bash Reference Manual},for @code{Bash}, Version @value{VERSION}.Copyright @copyright{} 1988--2011 Free Software Foundation, Inc.Permission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.@quotationPermission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.3 orany later version published by the Free Software Foundation; with noInvariant Sections, with the Front-Cover texts being ``A GNU Manual'',and with the Back-Cover Texts as in (a) below. A copy of the license isincluded in the section entitled ``GNU Free Documentation License''.(a) The FSF's Back-Cover Text is: You are free to copy and modifythis GNU manual. Buying copies from GNU Press supports the FSF indeveloping GNU and promoting software freedom.''@end quotation@end copying@defcodeindex bt@defcodeindex rw@set BashFeatures@dircategory Basics@direntry* Bash: (bash). The GNU Bourne-Again SHell.@end direntry@finalout@titlepage@title Bash Reference Manual@subtitle Reference Documentation for Bash@subtitle Edition @value{EDITION}, for @code{Bash} Version @value{VERSION}.@subtitle @value{UPDATED-MONTH}@author Chet Ramey, Case Western Reserve University@author Brian Fox, Free Software Foundation@page@vskip 0pt plus 1filll@insertcopying@sp 1Published by the Free Software Foundation @*59 Temple Place, Suite 330, @*Boston, MA 02111-1307 @*USA @*@end titlepage@contents@ifnottex@node Top, Introduction, (dir), (dir)@top Bash FeaturesThis text is a brief description of the features that are present inthe Bash shell (version @value{VERSION}, @value{UPDATED}).This is Edition @value{EDITION}, last updated @value{UPDATED},of @cite{The GNU Bash Reference Manual},for @code{Bash}, Version @value{VERSION}.Bash contains features that appear in other popular shells, and somefeatures that only appear in Bash. Some of the shells that Bash hasborrowed concepts from are the Bourne Shell (@file{sh}), the Korn Shell(@file{ksh}), and the C-shell (@file{csh} and its successor,@file{tcsh}). The following menu breaks the features up intocategories based upon which one of these other shells inspired thefeature.This manual is meant as a brief introduction to features found inBash. The Bash manual page should be used as the definitivereference on shell behavior.@menu* Introduction:: An introduction to the shell.* Definitions:: Some definitions used in the rest of this manual.* Basic Shell Features:: The shell "building blocks".* Shell Builtin Commands:: Commands that are a part of the shell.* Shell Variables:: Variables used or set by Bash.* Bash Features:: Features found only in Bash.* Job Control:: What job control is and how Bash allows you to use it.* Command Line Editing:: Chapter describing the command line editing features.* Using History Interactively:: Command History Expansion* Installing Bash:: How to build and install Bash on your system.* Reporting Bugs:: How to report bugs in Bash.* Major Differences From The Bourne Shell:: A terse list of the differences between Bash and historical versions of /bin/sh.* GNU Free Documentation License:: Copying and sharing this documentation.* Indexes:: Various indexes for this manual.@end menu@end ifnottex@node Introduction@chapter Introduction@menu* What is Bash?:: A short description of Bash.* What is a shell?:: A brief introduction to shells.@end menu@node What is Bash?@section What is Bash?Bash is the shell, or command language interpreter,for the @sc{gnu} operating system.The name is an acronym for the @samp{Bourne-Again SHell},a pun on Stephen Bourne, the author of the direct ancestor ofthe current Unix shell @code{sh}, which appeared in the Seventh Edition Bell Labs Research versionof Unix.Bash is largely compatible with @code{sh} and incorporates usefulfeatures from the Korn shell @code{ksh} and the C shell @code{csh}.It is intended to be a conformant implementation of the @sc{ieee}@sc{posix} Shell and Tools portion of the @sc{ieee} @sc{posix}specification (@sc{ieee} Standard 1003.1).It offers functional improvements over @code{sh} for both interactive andprogramming use.While the @sc{gnu} operating system provides other shells, includinga version of @code{csh}, Bash is the default shell.Like other @sc{gnu} software, Bash is quite portable. It currently runson nearly every version of Unix and a few other operating systems @minus{}independently-supported ports exist for @sc{ms-dos}, @sc{os/2},and Windows platforms.@node What is a shell?@section What is a shell?At its base, a shell is simply a macro processor that executescommands. The term macro processor means functionality where textand symbols are expanded to create larger expressions.A Unix shell is both a command interpreter and a programminglanguage. As a command interpreter, the shell provides the userinterface to the rich set of @sc{gnu} utilities. The programminglanguage features allow these utilities to be combined.Files containing commands can be created, and becomecommands themselves. These new commands have the same status assystem commands in directories such as @file{/bin}, allowing usersor groups to establish custom environments to automate their commontasks.Shells may be used interactively or non-interactively. Ininteractive mode, they accept input typed from the keyboard.When executing non-interactively, shells execute commands readfrom a file.A shell allows execution of @sc{gnu} commands, both synchronously andasynchronously.The shell waits for synchronous commands to complete before acceptingmore input; asynchronous commands continue to execute in parallelwith the shell while it reads and executes additional commands.The @dfn{redirection} constructs permitfine-grained control of the input and output of those commands.Moreover, the shell allows control over the contents of commands'environments.Shells also provide a small set of built-incommands (@dfn{builtins}) implementing functionality impossibleor inconvenient to obtain via separate utilities.For example, @code{cd}, @code{break}, @code{continue}, and@code{exec}) cannot be implemented outside of the shell becausethey directly manipulate the shell itself.The @code{history}, @code{getopts}, @code{kill}, or @code{pwd}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 insubsequent sections.While executing commands is essential, most of the power (andcomplexity) of shells is due to their embedded programminglanguages. Like any high-level language, the shell providesvariables, flow control constructs, quoting, and functions. Shells offer features geared specifically forinteractive use rather than to augment the programming language. These interactive features include job control, command lineediting, command history and aliases. Each of these features isdescribed in this manual.@node Definitions@chapter DefinitionsThese definitions are used throughout the remainder of this manual.@table @code@item POSIX@cindex POSIXA family of open system standards based on Unix. Bashis primarily concerned with the Shell and Utilities portion of the@sc{posix} 1003.1 standard. @item blankA space or tab character.@item builtin@cindex builtinA command that is implemented internally by the shell itself, ratherthan by an executable program somewhere in the file system.@item control operator@cindex control operatorA @code{token} that performs a control function. It is a @code{newline}or one of the following:@samp{||}, @samp{&&}, @samp{&}, @samp{;}, @samp{;;},@samp{|}, @samp{|&}, @samp{(}, or @samp{)}.@item exit status@cindex exit statusThe value returned by a command to its caller. The value is restrictedto eight bits, so the maximum value is 255.@item field@cindex fieldA unit of text that is the result of one of the shell expansions. Afterexpansion, when executing a command, the resulting fields are used asthe command name and arguments.@item filename@cindex filenameA string of characters used to identify a file.@item job@cindex jobA set of processes comprising a pipeline, and any processes descendedfrom it, that are all in the same process group.@item job control@cindex job controlA mechanism by which users can selectively stop (suspend) and restart(resume) execution of processes.@item metacharacter@cindex metacharacterA character that, when unquoted, separates words. A metacharacter isa @code{blank} or one of the following characters:@samp{|}, @samp{&}, @samp{;}, @samp{(}, @samp{)}, @samp{<}, or@samp{>}.@item name@cindex name@cindex identifierA @code{word} consisting solely of letters, numbers, and underscores,and beginning with a letter or underscore. @code{Name}s are used asshell variable and function names.Also referred to as an @code{identifier}.@item operator@cindex operator, shellA @code{control operator} or a @code{redirection operator}.@xref{Redirections}, for a list of redirection operators.Operators contain at least one unquoted @code{metacharacter}.@item process group@cindex process groupA collection of related processes each having the same processgroup @sc{id}.@item process group ID@cindex process group IDA unique identifier that represents a @code{process group}during its lifetime.@item reserved word@cindex reserved wordA @code{word} that has a special meaning to the shell. Most reservedwords introduce shell flow control constructs, such as @code{for} and@code{while}.@item return status@cindex return statusA synonym for @code{exit status}.@item signal@cindex signalA mechanism by which a process may be notified by the kernelof an event occurring in the system.@item special builtin@cindex special builtinA shell builtin command that has been classified as special by the@sc{posix} standard.@item token@cindex tokenA sequence of characters considered a single unit by the shell.It is either a @code{word} or an @code{operator}.@item word@cindex wordA sequence of characters treated as a unit by the shell.Words may not include unquoted @code{metacharacters}.@end table@node Basic Shell Features@chapter Basic Shell Features@cindex Bourne shellBash is an acronym for @samp{Bourne-Again SHell}.The Bourne shell isthe 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 @sc{posix}specification for the `standard' Unix shell.This chapter briefly summarizes the shell's `building blocks':commands, control structures, shell functions, shell @i{parameters},shell expansions,@i{redirections}, which are a way to direct input and output fromand to named files, and how the shell executes commands.@menu* Shell Syntax:: What your input means to the shell.* Shell Commands:: The types of commands you can use.* Shell Functions:: Grouping commands by name.* Shell Parameters:: How the shell stores values.* Shell Expansions:: How Bash expands parameters and the various expansions available.* Redirections:: A way to control where input and output go.* Executing Commands:: What happens when you run a command.* Shell Scripts:: Executing files of shell commands.@end menu@node Shell Syntax@section Shell Syntax@menu* Shell Operation:: The basic operation of the shell.* Quoting:: How to remove the special meaning from characters.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -