· 9 years ago · Nov 04, 2016, 01:32 PM
1BASH(1) General Commands Manual BASH(1)
2
3NAME
4 bash - GNU Bourne-Again SHell
5
6SYNOPSIS
7 bash [options] [command_string | file]
8
9COPYRIGHT
10 Bash is Copyright (C) 1989-2013 by the Free Software Foundation, Inc.
11
12DESCRIPTION
13 Bash is an sh-compatible command language interpreter that executes
14 commands read from the standard input or from a file. Bash also incorâ€
15 porates useful features from the Korn and C shells (ksh and csh).
16
17 Bash is intended to be a conformant implementation of the Shell and
18 Utilities portion of the IEEE POSIX specification (IEEE Standard
19 1003.1). Bash can be configured to be POSIX-conformant by default.
20
21OPTIONS
22 All of the single-character shell options documented in the descripâ€
23 tion of the set builtin command can be used as options when the shell
24 is invoked. In addition, bash interprets the following options when it
25 is invoked:
26
27 -c If the -c option is present, then commands are read from the
28 first non-option argument command_string. If there are arguâ€
29 ments after the command_string, they are assigned to the
30 positional parameters, starting with $0.
31 -i If the -i option is present, the shell is interactive.
32 -l Make bash act as if it had been invoked as a login shell (see
33 INVOCATION below).
34 -r If the -r option is present, the shell becomes restricted
35 (see RESTRICTED SHELL below).
36 -s If the -s option is present, or if no arguments remain after
37 option processing, then commands are read from the standard
38 input. This option allows the positional parameters to be
39 set when invoking an interactive shell.
40 -D A list of all double-quoted strings preceded by $ is printed
41 on the standard output. These are the strings that are subâ€
42 ject to language translation when the current locale is not C
43 or POSIX. This implies the -n option; no commands will be
44 executed.
45 [-+]O [shopt_option]
46 shopt_option is one of the shell options accepted by the
47 shopt builtin (see SHELL BUILTIN COMMANDS below). If
48 shopt_option is present, -O sets the value of that option; +O
49 unsets it. If shopt_option is not supplied, the names and
50 values of the shell options accepted by shopt are printed on
51 the standard output. If the invocation option is +O, the
52 output is displayed in a format that may be reused as input.
53 -- A -- signals the end of options and disables further option
54 processing. Any arguments after the -- are treated as fileâ€
55 names and arguments. An argument of - is equivalent to --.
56
57 Bash also interprets a number of multi-character options. These
58 options must appear on the command line before the single-character
59 options to be recognized.
60
61 --debugger
62 Arrange for the debugger profile to be executed before the shell
63 starts. Turns on extended debugging mode (see the description
64 of the extdebug option to the shopt builtin below).
65 --dump-po-strings
66 Equivalent to -D, but the output is in the GNU gettext po (porâ€
67 table object) file format.
68 --dump-strings
69 Equivalent to -D.
70 --help Display a usage message on standard output and exit successâ€
71 fully.
72 --init-file file
73 --rcfile file
74 Execute commands from file instead of the standard personal iniâ€
75 tialization file ~/.bashrc if the shell is interactive (see
76 INVOCATION below).
77
78 --login
79 Equivalent to -l.
80
81 --noediting
82 Do not use the GNU readline library to read command lines when
83 the shell is interactive.
84
85 --noprofile
86 Do not read either the system-wide startup file /etc/profile or
87 any of the personal initialization files ~/.bash_profile,
88 ~/.bash_login, or ~/.profile. By default, bash reads these
89 files when it is invoked as a login shell (see INVOCATION
90 below).
91
92 --norc Do not read and execute the personal initialization file
93 ~/.bashrc if the shell is interactive. This option is on by
94 default if the shell is invoked as sh.
95
96 --posix
97 Change the behavior of bash where the default operation differs
98 from the POSIX standard to match the standard (posix mode). See
99 SEE ALSO below for a reference to a document that details how
100 posix mode affects bash's behavior.
101
102 --restricted
103 The shell becomes restricted (see RESTRICTED SHELL below).
104
105 --rpm-requires
106 Produce the list of files that are required for the shell script
107 to run. This implies '-n' and is subject to the same limitaâ€
108 tions as compile time error checking checking; Command substituâ€
109 tions, Conditional expressions and eval builtin are not parsed
110 so some dependencies may be missed.
111
112 --verbose
113 Equivalent to -v.
114
115 --version
116 Show version information for this instance of bash on the stanâ€
117 dard output and exit successfully.
118
119ARGUMENTS
120 If arguments remain after option processing, and neither the -c nor the
121 -s option has been supplied, the first argument is assumed to be the
122 name of a file containing shell commands. If bash is invoked in this
123 fashion, $0 is set to the name of the file, and the positional parameâ€
124 ters are set to the remaining arguments. Bash reads and executes comâ€
125 mands from this file, then exits. Bash's exit status is the exit staâ€
126 tus of the last command executed in the script. If no commands are
127 executed, the exit status is 0. An attempt is first made to open the
128 file in the current directory, and, if no file is found, then the shell
129 searches the directories in PATH for the script.
130
131INVOCATION
132 A login shell is one whose first character of argument zero is a -, or
133 one started with the --login option.
134
135 An interactive shell is one started without non-option arguments and
136 without the -c option whose standard input and error are both connected
137 to terminals (as determined by isatty(3)), or one started with the -i
138 option. PS1 is set and $- includes i if bash is interactive, allowing
139 a shell script or a startup file to test this state.
140
141 The following paragraphs describe how bash executes its startup files.
142 If any of the files exist but cannot be read, bash reports an error.
143 Tildes are expanded in filenames as described below under Tilde Expanâ€
144 sion in the EXPANSION section.
145
146 When bash is invoked as an interactive login shell, or as a non-interâ€
147 active shell with the --login option, it first reads and executes comâ€
148 mands from the file /etc/profile, if that file exists. After reading
149 that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
150 in that order, and reads and executes commands from the first one that
151 exists and is readable. The --noprofile option may be used when the
152 shell is started to inhibit this behavior.
153
154 When a login shell exits, bash reads and executes commands from the
155 files ~/.bash_logout and /etc/bash.bash_logout, if the files exists.
156
157 When an interactive shell that is not a login shell is started, bash
158 reads and executes commands from ~/.bashrc, if that file exists. This
159 may be inhibited by using the --norc option. The --rcfile file option
160 will force bash to read and execute commands from file instead of
161 ~/.bashrc.
162
163 When bash is started non-interactively, to run a shell script, for
164 example, it looks for the variable BASH_ENV in the environment, expands
165 its value if it appears there, and uses the expanded value as the name
166 of a file to read and execute. Bash behaves as if the following comâ€
167 mand were executed:
168 if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
169 but the value of the PATH variable is not used to search for the fileâ€
170 name.
171
172 If bash is invoked with the name sh, it tries to mimic the startup
173 behavior of historical versions of sh as closely as possible, while
174 conforming to the POSIX standard as well. When invoked as an interacâ€
175 tive login shell, or a non-interactive shell with the --login option,
176 it first attempts to read and execute commands from /etc/profile and
177 ~/.profile, in that order. The --noprofile option may be used to
178 inhibit this behavior. When invoked as an interactive shell with the
179 name sh, bash looks for the variable ENV, expands its value if it is
180 defined, and uses the expanded value as the name of a file to read and
181 execute. Since a shell invoked as sh does not attempt to read and exeâ€
182 cute commands from any other startup files, the --rcfile option has no
183 effect. A non-interactive shell invoked with the name sh does not
184 attempt to read any other startup files. When invoked as sh, bash
185 enters posix mode after the startup files are read.
186
187 When bash is started in posix mode, as with the --posix command line
188 option, it follows the POSIX standard for startup files. In this mode,
189 interactive shells expand the ENV variable and commands are read and
190 executed from the file whose name is the expanded value. No other
191 startup files are read.
192
193 Bash attempts to determine when it is being run with its standard input
194 connected to a network connection, as when executed by the remote shell
195 daemon, usually rshd, or the secure shell daemon sshd. If bash deterâ€
196 mines it is being run in this fashion, it reads and executes commands
197 from ~/.bashrc, if that file exists and is readable. It will not do
198 this if invoked as sh. The --norc option may be used to inhibit this
199 behavior, and the --rcfile option may be used to force another file to
200 be read, but neither rshd nor sshd generally invoke the shell with
201 those options or allow them to be specified.
202
203 If the shell is started with the effective user (group) id not equal to
204 the real user (group) id, and the -p option is not supplied, no startup
205 files are read, shell functions are not inherited from the environment,
206 the SHELLOPTS, BASHOPTS, CDPATH, and GLOBIGNORE variables, if they
207 appear in the environment, are ignored, and the effective user id is
208 set to the real user id. If the -p option is supplied at invocation,
209 the startup behavior is the same, but the effective user id is not
210 reset.
211
212DEFINITIONS
213 The following definitions are used throughout the rest of this docuâ€
214 ment.
215 blank A space or tab.
216 word A sequence of characters considered as a single unit by the
217 shell. Also known as a token.
218 name A word consisting only of alphanumeric characters and underâ€
219 scores, and beginning with an alphabetic character or an underâ€
220 score. Also referred to as an identifier.
221 metacharacter
222 A character that, when unquoted, separates words. One of the
223 following:
224 | & ; ( ) < > space tab
225 control operator
226 A token that performs a control function. It is one of the folâ€
227 lowing symbols:
228 || & && ; ;; ( ) | |& <newline>
229
230RESERVED WORDS
231 Reserved words are words that have a special meaning to the shell. The
232 following words are recognized as reserved when unquoted and either the
233 first word of a simple command (see SHELL GRAMMAR below) or the third
234 word of a case or for command:
235
236 ! case coproc do done elif else esac fi for function if in select
237 then until while { } time [[ ]]
238
239SHELL GRAMMAR
240 Simple Commands
241 A simple command is a sequence of optional variable assignments folâ€
242 lowed by blank-separated words and redirections, and terminated by a
243 control operator. The first word specifies the command to be executed,
244 and is passed as argument zero. The remaining words are passed as
245 arguments to the invoked command.
246
247 The return value of a simple command is its exit status, or 128+n if
248 the command is terminated by signal n.
249
250 Pipelines
251 A pipeline is a sequence of one or more commands separated by one of
252 the control operators | or |&. The format for a pipeline is:
253
254 [time [-p]] [ ! ] command [ [|⎪|&] command2 ... ]
255
256 The standard output of command is connected via a pipe to the standard
257 input of command2. This connection is performed before any redirecâ€
258 tions specified by the command (see REDIRECTION below). If |& is used,
259 command's standard error, in addition to its standard output, is conâ€
260 nected to command2's standard input through the pipe; it is shorthand
261 for 2>&1 |. This implicit redirection of the standard error to the
262 standard output is performed after any redirections specified by the
263 command.
264
265 The return status of a pipeline is the exit status of the last command,
266 unless the pipefail option is enabled. If pipefail is enabled, the
267 pipeline's return status is the value of the last (rightmost) command
268 to exit with a non-zero status, or zero if all commands exit successâ€
269 fully. If the reserved word ! precedes a pipeline, the exit status of
270 that pipeline is the logical negation of the exit status as described
271 above. The shell waits for all commands in the pipeline to terminate
272 before returning a value.
273
274 If the time reserved word precedes a pipeline, the elapsed as well as
275 user and system time consumed by its execution are reported when the
276 pipeline terminates. The -p option changes the output format to that
277 specified by POSIX. When the shell is in posix mode, it does not recâ€
278 ognize time as a reserved word if the next token begins with a `-'.
279 The TIMEFORMAT variable may be set to a format string that specifies
280 how the timing information should be displayed; see the description of
281 TIMEFORMAT under Shell Variables below.
282
283 When the shell is in posix mode, time may be followed by a newline. In
284 this case, the shell displays the total user and system time consumed
285 by the shell and its children. The TIMEFORMAT variable may be used to
286 specify the format of the time information.
287
288 Each command in a pipeline is executed as a separate process (i.e., in
289 a subshell).
290
291 Lists
292 A list is a sequence of one or more pipelines separated by one of the
293 operators ;, &, &&, or ||, and optionally terminated by one of ;, &, or
294 <newline>.
295
296 Of these list operators, && and || have equal precedence, followed by ;
297 and &, which have equal precedence.
298
299 A sequence of one or more newlines may appear in a list instead of a
300 semicolon to delimit commands.
301
302 If a command is terminated by the control operator &, the shell exeâ€
303 cutes the command in the background in a subshell. The shell does not
304 wait for the command to finish, and the return status is 0. Commands
305 separated by a ; are executed sequentially; the shell waits for each
306 command to terminate in turn. The return status is the exit status of
307 the last command executed.
308
309 AND and OR lists are sequences of one of more pipelines separated by
310 the && and || control operators, respectively. AND and OR lists are
311 executed with left associativity. An AND list has the form
312
313 command1 && command2
314
315 command2 is executed if, and only if, command1 returns an exit status
316 of zero.
317
318 An OR list has the form
319
320 command1 || command2
321
322 command2 is executed if and only if command1 returns a non-zero exit
323 status. The return status of AND and OR lists is the exit status of
324 the last command executed in the list.
325
326 Compound Commands
327 A compound command is one of the following. In most cases a list in a
328 command's description may be separated from the rest of the command by
329 one or more newlines, and may be followed by a newline in place of a
330 semicolon.
331
332 (list) list is executed in a subshell environment (see COMMAND EXECUâ€
333 TION ENVIRONMENT below). Variable assignments and builtin comâ€
334 mands that affect the shell's environment do not remain in
335 effect after the command completes. The return status is the
336 exit status of list.
337
338 { list; }
339 list is simply executed in the current shell environment. list
340 must be terminated with a newline or semicolon. This is known
341 as a group command. The return status is the exit status of
342 list. Note that unlike the metacharacters ( and ), { and } are
343 reserved words and must occur where a reserved word is permitted
344 to be recognized. Since they do not cause a word break, they
345 must be separated from list by whitespace or another shell
346 metacharacter.
347
348 ((expression))
349 The expression is evaluated according to the rules described
350 below under ARITHMETIC EVALUATION. If the value of the expresâ€
351 sion is non-zero, the return status is 0; otherwise the return
352 status is 1. This is exactly equivalent to let "expression".
353
354 [[ expression ]]
355 Return a status of 0 or 1 depending on the evaluation of the
356 conditional expression expression. Expressions are composed of
357 the primaries described below under CONDITIONAL EXPRESSIONS.
358 Word splitting and pathname expansion are not performed on the
359 words between the [[ and ]]; tilde expansion, parameter and
360 variable expansion, arithmetic expansion, command substitution,
361 process substitution, and quote removal are performed. Condiâ€
362 tional operators such as -f must be unquoted to be recognized as
363 primaries.
364
365 When used with [[, the < and > operators sort lexicographically
366 using the current locale.
367
368 When the == and != operators are used, the string to the right
369 of the operator is considered a pattern and matched according to
370 the rules described below under Pattern Matching, as if the extâ€
371 glob shell option were enabled. The = operator is equivalent to
372 ==. If the shell option nocasematch is enabled, the match is
373 performed without regard to the case of alphabetic characters.
374 The return value is 0 if the string matches (==) or does not
375 match (!=) the pattern, and 1 otherwise. Any part of the patâ€
376 tern may be quoted to force the quoted portion to be matched as
377 a string.
378
379 An additional binary operator, =~, is available, with the same
380 precedence as == and !=. When it is used, the string to the
381 right of the operator is considered an extended regular expresâ€
382 sion and matched accordingly (as in regex(3)). The return value
383 is 0 if the string matches the pattern, and 1 otherwise. If the
384 regular expression is syntactically incorrect, the conditional
385 expression's return value is 2. If the shell option nocasematch
386 is enabled, the match is performed without regard to the case of
387 alphabetic characters. Any part of the pattern may be quoted to
388 force the quoted portion to be matched as a string. Bracket
389 expressions in regular expressions must be treated carefully,
390 since normal quoting characters lose their meanings between
391 brackets. If the pattern is stored in a shell variable, quoting
392 the variable expansion forces the entire pattern to be matched
393 as a string. Substrings matched by parenthesized subexpressions
394 within the regular expression are saved in the array variable
395 BASH_REMATCH. The element of BASH_REMATCH with index 0 is the
396 portion of the string matching the entire regular expression.
397 The element of BASH_REMATCH with index n is the portion of the
398 string matching the nth parenthesized subexpression.
399
400 Expressions may be combined using the following operators,
401 listed in decreasing order of precedence:
402
403 ( expression )
404 Returns the value of expression. This may be used to
405 override the normal precedence of operators.
406 ! expression
407 True if expression is false.
408 expression1 && expression2
409 True if both expression1 and expression2 are true.
410 expression1 || expression2
411 True if either expression1 or expression2 is true.
412
413 The && and || operators do not evaluate expression2 if the value
414 of expression1 is sufficient to determine the return value of
415 the entire conditional expression.
416
417 for name [ [ in [ word ... ] ] ; ] do list ; done
418 The list of words following in is expanded, generating a list of
419 items. The variable name is set to each element of this list in
420 turn, and list is executed each time. If the in word is omitâ€
421 ted, the for command executes list once for each positional
422 parameter that is set (see PARAMETERS below). The return status
423 is the exit status of the last command that executes. If the
424 expansion of the items following in results in an empty list, no
425 commands are executed, and the return status is 0.
426
427 for (( expr1 ; expr2 ; expr3 )) ; do list ; done
428 First, the arithmetic expression expr1 is evaluated according to
429 the rules described below under ARITHMETIC EVALUATION. The
430 arithmetic expression expr2 is then evaluated repeatedly until
431 it evaluates to zero. Each time expr2 evaluates to a non-zero
432 value, list is executed and the arithmetic expression expr3 is
433 evaluated. If any expression is omitted, it behaves as if it
434 evaluates to 1. The return value is the exit status of the last
435 command in list that is executed, or false if any of the expresâ€
436 sions is invalid.
437
438 select name [ in word ] ; do list ; done
439 The list of words following in is expanded, generating a list of
440 items. The set of expanded words is printed on the standard
441 error, each preceded by a number. If the in word is omitted,
442 the positional parameters are printed (see PARAMETERS below).
443 The PS3 prompt is then displayed and a line read from the stanâ€
444 dard input. If the line consists of a number corresponding to
445 one of the displayed words, then the value of name is set to
446 that word. If the line is empty, the words and prompt are disâ€
447 played again. If EOF is read, the command completes. Any other
448 value read causes name to be set to null. The line read is
449 saved in the variable REPLY. The list is executed after each
450 selection until a break command is executed. The exit status of
451 select is the exit status of the last command executed in list,
452 or zero if no commands were executed.
453
454 case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac
455 A case command first expands word, and tries to match it against
456 each pattern in turn, using the same matching rules as for pathâ€
457 name expansion (see Pathname Expansion below). The word is
458 expanded using tilde expansion, parameter and variable expanâ€
459 sion, arithmetic substitution, command substitution, process
460 substitution and quote removal. Each pattern examined is
461 expanded using tilde expansion, parameter and variable expanâ€
462 sion, arithmetic substitution, command substitution, and process
463 substitution. If the shell option nocasematch is enabled, the
464 match is performed without regard to the case of alphabetic
465 characters. When a match is found, the corresponding list is
466 executed. If the ;; operator is used, no subsequent matches are
467 attempted after the first pattern match. Using ;& in place of
468 ;; causes execution to continue with the list associated with
469 the next set of patterns. Using ;;& in place of ;; causes the
470 shell to test the next pattern list in the statement, if any,
471 and execute any associated list on a successful match. The exit
472 status is zero if no pattern matches. Otherwise, it is the exit
473 status of the last command executed in list.
474
475 if list; then list; [ elif list; then list; ] ... [ else list; ] fi
476 The if list is executed. If its exit status is zero, the then
477 list is executed. Otherwise, each elif list is executed in
478 turn, and if its exit status is zero, the corresponding then
479 list is executed and the command completes. Otherwise, the else
480 list is executed, if present. The exit status is the exit staâ€
481 tus of the last command executed, or zero if no condition tested
482 true.
483
484 while list-1; do list-2; done
485 until list-1; do list-2; done
486 The while command continuously executes the list list-2 as long
487 as the last command in the list list-1 returns an exit status of
488 zero. The until command is identical to the while command,
489 except that the test is negated; list-2 is executed as long as
490 the last command in list-1 returns a non-zero exit status. The
491 exit status of the while and until commands is the exit status
492 of the last command executed in list-2, or zero if none was exeâ€
493 cuted.
494
495 Coprocesses
496 A coprocess is a shell command preceded by the coproc reserved word. A
497 coprocess is executed asynchronously in a subshell, as if the command
498 had been terminated with the & control operator, with a two-way pipe
499 established between the executing shell and the coprocess.
500
501 The format for a coprocess is:
502
503 coproc [NAME] command [redirections]
504
505 This creates a coprocess named NAME. If NAME is not supplied, the
506 default name is COPROC. NAME must not be supplied if command is a simâ€
507 ple command (see above); otherwise, it is interpreted as the first word
508 of the simple command. When the coprocess is executed, the shell creâ€
509 ates an array variable (see Arrays below) named NAME in the context of
510 the executing shell. The standard output of command is connected via a
511 pipe to a file descriptor in the executing shell, and that file
512 descriptor is assigned to NAME[0]. The standard input of command is
513 connected via a pipe to a file descriptor in the executing shell, and
514 that file descriptor is assigned to NAME[1]. This pipe is established
515 before any redirections specified by the command (see REDIRECTION
516 below). The file descriptors can be utilized as arguments to shell
517 commands and redirections using standard word expansions. The file
518 descriptors are not available in subshells. The process ID of the
519 shell spawned to execute the coprocess is available as the value of the
520 variable NAME_PID. The wait builtin command may be used to wait for
521 the coprocess to terminate.
522
523 Since the coprocess is created as an asynchronous command, the coproc
524 command always returns success. The return status of a coprocess is
525 the exit status of command.
526
527 Shell Function Definitions
528 A shell function is an object that is called like a simple command and
529 executes a compound command with a new set of positional parameters.
530 Shell functions are declared as follows:
531
532 name () compound-command [redirection]
533 function name [()] compound-command [redirection]
534 This defines a function named name. The reserved word function
535 is optional. If the function reserved word is supplied, the
536 parentheses are optional. The body of the function is the comâ€
537 pound command compound-command (see Compound Commands above).
538 That command is usually a list of commands between { and }, but
539 may be any command listed under Compound Commands above. comâ€
540 pound-command is executed whenever name is specified as the name
541 of a simple command. When in posix mode, name may not be the
542 name of one of the POSIX special builtins. Any redirections
543 (see REDIRECTION below) specified when a function is defined are
544 performed when the function is executed. The exit status of a
545 function definition is zero unless a syntax error occurs or a
546 readonly function with the same name already exists. When exeâ€
547 cuted, the exit status of a function is the exit status of the
548 last command executed in the body. (See FUNCTIONS below.)
549
550COMMENTS
551 In a non-interactive shell, or an interactive shell in which the interâ€
552 active_comments option to the shopt builtin is enabled (see SHELL
553 BUILTIN COMMANDS below), a word beginning with # causes that word and
554 all remaining characters on that line to be ignored. An interactive
555 shell without the interactive_comments option enabled does not allow
556 comments. The interactive_comments option is on by default in interacâ€
557 tive shells.
558
559QUOTING
560 Quoting is used to remove the special meaning of certain characters or
561 words to the shell. Quoting can be used to disable special treatment
562 for special characters, to prevent reserved words from being recognized
563 as such, and to prevent parameter expansion.
564
565 Each of the metacharacters listed above under DEFINITIONS has special
566 meaning to the shell and must be quoted if it is to represent itself.
567
568 When the command history expansion facilities are being used (see HISâ€
569 TORY EXPANSION below), the history expansion character, usually !, must
570 be quoted to prevent history expansion.
571
572 There are three quoting mechanisms: the escape character, single
573 quotes, and double quotes.
574
575 A non-quoted backslash (\) is the escape character. It preserves the
576 literal value of the next character that follows, with the exception of
577 <newline>. If a \<newline> pair appears, and the backslash is not
578 itself quoted, the \<newline> is treated as a line continuation (that
579 is, it is removed from the input stream and effectively ignored).
580
581 Enclosing characters in single quotes preserves the literal value of
582 each character within the quotes. A single quote may not occur between
583 single quotes, even when preceded by a backslash.
584
585 Enclosing characters in double quotes preserves the literal value of
586 all characters within the quotes, with the exception of $, `, \, and,
587 when history expansion is enabled, !. The characters $ and ` retain
588 their special meaning within double quotes. The backslash retains its
589 special meaning only when followed by one of the following characters:
590 $, `, ", \, or <newline>. A double quote may be quoted within double
591 quotes by preceding it with a backslash. If enabled, history expansion
592 will be performed unless an ! appearing in double quotes is escaped
593 using a backslash. The backslash preceding the ! is not removed.
594
595 The special parameters * and @ have special meaning when in double
596 quotes (see PARAMETERS below).
597
598 Words of the form $'string' are treated specially. The word expands to
599 string, with backslash-escaped characters replaced as specified by the
600 ANSI C standard. Backslash escape sequences, if present, are decoded
601 as follows:
602 \a alert (bell)
603 \b backspace
604 \e
605 \E an escape character
606 \f form feed
607 \n new line
608 \r carriage return
609 \t horizontal tab
610 \v vertical tab
611 \\ backslash
612 \' single quote
613 \" double quote
614 \nnn the eight-bit character whose value is the octal value
615 nnn (one to three digits)
616 \xHH the eight-bit character whose value is the hexadecimal
617 value HH (one or two hex digits)
618 \uHHHH the Unicode (ISO/IEC 10646) character whose value is the
619 hexadecimal value HHHH (one to four hex digits)
620 \UHHHHHHHH
621 the Unicode (ISO/IEC 10646) character whose value is the
622 hexadecimal value HHHHHHHH (one to eight hex digits)
623 \cx a control-x character
624
625 The expanded result is single-quoted, as if the dollar sign had not
626 been present.
627
628 A double-quoted string preceded by a dollar sign ($"string") will cause
629 the string to be translated according to the current locale. If the
630 current locale is C or POSIX, the dollar sign is ignored. If the
631 string is translated and replaced, the replacement is double-quoted.
632
633PARAMETERS
634 A parameter is an entity that stores values. It can be a name, a numâ€
635 ber, or one of the special characters listed below under Special Paramâ€
636 eters. A variable is a parameter denoted by a name. A variable has a
637 value and zero or more attributes. Attributes are assigned using the
638 declare builtin command (see declare below in SHELL BUILTIN COMMANDS).
639
640 A parameter is set if it has been assigned a value. The null string is
641 a valid value. Once a variable is set, it may be unset only by using
642 the unset builtin command (see SHELL BUILTIN COMMANDS below).
643
644 A variable may be assigned to by a statement of the form
645
646 name=[value]
647
648 If value is not given, the variable is assigned the null string. All
649 values undergo tilde expansion, parameter and variable expansion, comâ€
650 mand substitution, arithmetic expansion, and quote removal (see EXPANâ€
651 SION below). If the variable has its integer attribute set, then value
652 is evaluated as an arithmetic expression even if the $((...)) expansion
653 is not used (see Arithmetic Expansion below). Word splitting is not
654 performed, with the exception of "$@" as explained below under Special
655 Parameters. Pathname expansion is not performed. Assignment stateâ€
656 ments may also appear as arguments to the alias, declare, typeset,
657 export, readonly, and local builtin commands. When in posix mode,
658 these builtins may appear in a command after one or more instances of
659 the command builtin and retain these assignment statement properties.
660
661 In the context where an assignment statement is assigning a value to a
662 shell variable or array index, the += operator can be used to append to
663 or add to the variable's previous value. When += is applied to a variâ€
664 able for which the integer attribute has been set, value is evaluated
665 as an arithmetic expression and added to the variable's current value,
666 which is also evaluated. When += is applied to an array variable using
667 compound assignment (see Arrays below), the variable's value is not
668 unset (as it is when using =), and new values are appended to the array
669 beginning at one greater than the array's maximum index (for indexed
670 arrays) or added as additional key-value pairs in an associative array.
671 When applied to a string-valued variable, value is expanded and
672 appended to the variable's value.
673
674 A variable can be assigned the nameref attribute using the -n option to
675 the declare or local builtin commands (see the descriptions of declare
676 and local below) to create a nameref, or a reference to another variâ€
677 able. This allows variables to be manipulated indirectly. Whenever
678 the nameref variable is referenced or assigned to, the operation is
679 actually performed on the variable specified by the nameref variable's
680 value. A nameref is commonly used within shell functions to refer to a
681 variable whose name is passed as an argument to the function. For
682 instance, if a variable name is passed to a shell function as its first
683 argument, running
684 declare -n ref=$1
685 inside the function creates a nameref variable ref whose value is the
686 variable name passed as the first argument. References and assignments
687 to ref are treated as references and assignments to the variable whose
688 name was passed as $1. If the control variable in a for loop has the
689 nameref attribute, the list of words can be a list of shell variables,
690 and a name reference will be established for each word in the list, in
691 turn, when the loop is executed. Array variables cannot be given the
692 -n attribute. However, nameref variables can reference array variables
693 and subscripted array variables. Namerefs can be unset using the -n
694 option to the unset builtin. Otherwise, if unset is executed with the
695 name of a nameref variable as an argument, the variable referenced by
696 the nameref variable will be unset.
697
698 Positional Parameters
699 A positional parameter is a parameter denoted by one or more digits,
700 other than the single digit 0. Positional parameters are assigned from
701 the shell's arguments when it is invoked, and may be reassigned using
702 the set builtin command. Positional parameters may not be assigned to
703 with assignment statements. The positional parameters are temporarily
704 replaced when a shell function is executed (see FUNCTIONS below).
705
706 When a positional parameter consisting of more than a single digit is
707 expanded, it must be enclosed in braces (see EXPANSION below).
708
709 Special Parameters
710 The shell treats several parameters specially. These parameters may
711 only be referenced; assignment to them is not allowed.
712 * Expands to the positional parameters, starting from one. When
713 the expansion is not within double quotes, each positional
714 parameter expands to a separate word. In contexts where it is
715 performed, those words are subject to further word splitting and
716 pathname expansion. When the expansion occurs within double
717 quotes, it expands to a single word with the value of each
718 parameter separated by the first character of the IFS special
719 variable. That is, "$*" is equivalent to "$1c$2c...", where c
720 is the first character of the value of the IFS variable. If IFS
721 is unset, the parameters are separated by spaces. If IFS is
722 null, the parameters are joined without intervening separators.
723 @ Expands to the positional parameters, starting from one. When
724 the expansion occurs within double quotes, each parameter
725 expands to a separate word. That is, "$@" is equivalent to "$1"
726 "$2" ... If the double-quoted expansion occurs within a word,
727 the expansion of the first parameter is joined with the beginâ€
728 ning part of the original word, and the expansion of the last
729 parameter is joined with the last part of the original word.
730 When there are no positional parameters, "$@" and $@ expand to
731 nothing (i.e., they are removed).
732 # Expands to the number of positional parameters in decimal.
733 ? Expands to the exit status of the most recently executed foreâ€
734 ground pipeline.
735 - Expands to the current option flags as specified upon invocaâ€
736 tion, by the set builtin command, or those set by the shell
737 itself (such as the -i option).
738 $ Expands to the process ID of the shell. In a () subshell, it
739 expands to the process ID of the current shell, not the subâ€
740 shell.
741 ! Expands to the process ID of the job most recently placed into
742 the background, whether executed as an asynchronous command or
743 using the bg builtin (see JOB CONTROL below).
744 0 Expands to the name of the shell or shell script. This is set
745 at shell initialization. If bash is invoked with a file of comâ€
746 mands, $0 is set to the name of that file. If bash is started
747 with the -c option, then $0 is set to the first argument after
748 the string to be executed, if one is present. Otherwise, it is
749 set to the filename used to invoke bash, as given by argument
750 zero.
751 _ At shell startup, set to the absolute pathname used to invoke
752 the shell or shell script being executed as passed in the enviâ€
753 ronment or argument list. Subsequently, expands to the last
754 argument to the previous command, after expansion. Also set to
755 the full pathname used to invoke each command executed and
756 placed in the environment exported to that command. When checkâ€
757 ing mail, this parameter holds the name of the mail file curâ€
758 rently being checked.
759
760 Shell Variables
761 The following variables are set by the shell:
762
763 BASH Expands to the full filename used to invoke this instance of
764 bash.
765 BASHOPTS
766 A colon-separated list of enabled shell options. Each word in
767 the list is a valid argument for the -s option to the shopt
768 builtin command (see SHELL BUILTIN COMMANDS below). The options
769 appearing in BASHOPTS are those reported as on by shopt. If
770 this variable is in the environment when bash starts up, each
771 shell option in the list will be enabled before reading any
772 startup files. This variable is read-only.
773 BASHPID
774 Expands to the process ID of the current bash process. This
775 differs from $$ under certain circumstances, such as subshells
776 that do not require bash to be re-initialized.
777 BASH_ALIASES
778 An associative array variable whose members correspond to the
779 internal list of aliases as maintained by the alias builtin.
780 Elements added to this array appear in the alias list; unsetting
781 array elements cause aliases to be removed from the alias list.
782 BASH_ARGC
783 An array variable whose values are the number of parameters in
784 each frame of the current bash execution call stack. The number
785 of parameters to the current subroutine (shell function or
786 script executed with . or source) is at the top of the stack.
787 When a subroutine is executed, the number of parameters passed
788 is pushed onto BASH_ARGC. The shell sets BASH_ARGC only when in
789 extended debugging mode (see the description of the extdebug
790 option to the shopt builtin below)
791 BASH_ARGV
792 An array variable containing all of the parameters in the curâ€
793 rent bash execution call stack. The final parameter of the last
794 subroutine call is at the top of the stack; the first parameter
795 of the initial call is at the bottom. When a subroutine is exeâ€
796 cuted, the parameters supplied are pushed onto BASH_ARGV. The
797 shell sets BASH_ARGV only when in extended debugging mode (see
798 the description of the extdebug option to the shopt builtin
799 below)
800 BASH_CMDS
801 An associative array variable whose members correspond to the
802 internal hash table of commands as maintained by the hash
803 builtin. Elements added to this array appear in the hash table;
804 unsetting array elements cause commands to be removed from the
805 hash table.
806 BASH_COMMAND
807 The command currently being executed or about to be executed,
808 unless the shell is executing a command as the result of a trap,
809 in which case it is the command executing at the time of the
810 trap.
811 BASH_EXECUTION_STRING
812 The command argument to the -c invocation option.
813 BASH_LINENO
814 An array variable whose members are the line numbers in source
815 files where each corresponding member of FUNCNAME was invoked.
816 ${BASH_LINENO[$i]} is the line number in the source file
817 (${BASH_SOURCE[$i+1]}) where ${FUNCNAME[$i]} was called (or
818 ${BASH_LINENO[$i-1]} if referenced within another shell funcâ€
819 tion). Use LINENO to obtain the current line number.
820 BASH_REMATCH
821 An array variable whose members are assigned by the =~ binary
822 operator to the [[ conditional command. The element with index
823 0 is the portion of the string matching the entire regular
824 expression. The element with index n is the portion of the
825 string matching the nth parenthesized subexpression. This variâ€
826 able is read-only.
827 BASH_SOURCE
828 An array variable whose members are the source filenames where
829 the corresponding shell function names in the FUNCNAME array
830 variable are defined. The shell function ${FUNCNAME[$i]} is
831 defined in the file ${BASH_SOURCE[$i]} and called from
832 ${BASH_SOURCE[$i+1]}.
833 BASH_SUBSHELL
834 Incremented by one within each subshell or subshell environment
835 when the shell begins executing in that environment. The iniâ€
836 tial value is 0.
837 BASH_VERSINFO
838 A readonly array variable whose members hold version information
839 for this instance of bash. The values assigned to the array
840 members are as follows:
841 BASH_VERSINFO[0] The major version number (the release).
842 BASH_VERSINFO[1] The minor version number (the version).
843 BASH_VERSINFO[2] The patch level.
844 BASH_VERSINFO[3] The build version.
845 BASH_VERSINFO[4] The release status (e.g., beta1).
846 BASH_VERSINFO[5] The value of MACHTYPE.
847 BASH_VERSION
848 Expands to a string describing the version of this instance of
849 bash.
850 COMP_CWORD
851 An index into ${COMP_WORDS} of the word containing the current
852 cursor position. This variable is available only in shell funcâ€
853 tions invoked by the programmable completion facilities (see
854 Programmable Completion below).
855 COMP_KEY
856 The key (or final key of a key sequence) used to invoke the curâ€
857 rent completion function.
858 COMP_LINE
859 The current command line. This variable is available only in
860 shell functions and external commands invoked by the programâ€
861 mable completion facilities (see Programmable Completion below).
862 COMP_POINT
863 The index of the current cursor position relative to the beginâ€
864 ning of the current command. If the current cursor position is
865 at the end of the current command, the value of this variable is
866 equal to ${#COMP_LINE}. This variable is available only in
867 shell functions and external commands invoked by the programâ€
868 mable completion facilities (see Programmable Completion below).
869 COMP_TYPE
870 Set to an integer value corresponding to the type of completion
871 attempted that caused a completion function to be called: TAB,
872 for normal completion, ?, for listing completions after succesâ€
873 sive tabs, !, for listing alternatives on partial word compleâ€
874 tion, @, to list completions if the word is not unmodified, or
875 %, for menu completion. This variable is available only in
876 shell functions and external commands invoked by the programâ€
877 mable completion facilities (see Programmable Completion below).
878 COMP_WORDBREAKS
879 The set of characters that the readline library treats as word
880 separators when performing word completion. If COMP_WORDBREAKS
881 is unset, it loses its special properties, even if it is subseâ€
882 quently reset.
883 COMP_WORDS
884 An array variable (see Arrays below) consisting of the individâ€
885 ual words in the current command line. The line is split into
886 words as readline would split it, using COMP_WORDBREAKS as
887 described above. This variable is available only in shell funcâ€
888 tions invoked by the programmable completion facilities (see
889 Programmable Completion below).
890 COPROC An array variable (see Arrays below) created to hold the file
891 descriptors for output from and input to an unnamed coprocess
892 (see Coprocesses above).
893 DIRSTACK
894 An array variable (see Arrays below) containing the current conâ€
895 tents of the directory stack. Directories appear in the stack
896 in the order they are displayed by the dirs builtin. Assigning
897 to members of this array variable may be used to modify directoâ€
898 ries already in the stack, but the pushd and popd builtins must
899 be used to add and remove directories. Assignment to this variâ€
900 able will not change the current directory. If DIRSTACK is
901 unset, it loses its special properties, even if it is subseâ€
902 quently reset.
903 EUID Expands to the effective user ID of the current user, initialâ€
904 ized at shell startup. This variable is readonly.
905 FUNCNAME
906 An array variable containing the names of all shell functions
907 currently in the execution call stack. The element with index 0
908 is the name of any currently-executing shell function. The botâ€
909 tom-most element (the one with the highest index) is "main".
910 This variable exists only when a shell function is executing.
911 Assignments to FUNCNAME have no effect and return an error staâ€
912 tus. If FUNCNAME is unset, it loses its special properties,
913 even if it is subsequently reset.
914
915 This variable can be used with BASH_LINENO and BASH_SOURCE.
916 Each element of FUNCNAME has corresponding elements in
917 BASH_LINENO and BASH_SOURCE to describe the call stack. For
918 instance, ${FUNCNAME[$i]} was called from the file
919 ${BASH_SOURCE[$i+1]} at line number ${BASH_LINENO[$i]}. The
920 caller builtin displays the current call stack using this inforâ€
921 mation.
922 GROUPS An array variable containing the list of groups of which the
923 current user is a member. Assignments to GROUPS have no effect
924 and return an error status. If GROUPS is unset, it loses its
925 special properties, even if it is subsequently reset.
926 HISTCMD
927 The history number, or index in the history list, of the current
928 command. If HISTCMD is unset, it loses its special properties,
929 even if it is subsequently reset.
930 HOSTNAME
931 Automatically set to the name of the current host.
932 HOSTTYPE
933 Automatically set to a string that uniquely describes the type
934 of machine on which bash is executing. The default is system-
935 dependent.
936 LINENO Each time this parameter is referenced, the shell substitutes a
937 decimal number representing the current sequential line number
938 (starting with 1) within a script or function. When not in a
939 script or function, the value substituted is not guaranteed to
940 be meaningful. If LINENO is unset, it loses its special properâ€
941 ties, even if it is subsequently reset.
942 MACHTYPE
943 Automatically set to a string that fully describes the system
944 type on which bash is executing, in the standard GNU cpu-comâ€
945 pany-system format. The default is system-dependent.
946 MAPFILE
947 An array variable (see Arrays below) created to hold the text
948 read by the mapfile builtin when no variable name is supplied.
949 OLDPWD The previous working directory as set by the cd command.
950 OPTARG The value of the last option argument processed by the getopts
951 builtin command (see SHELL BUILTIN COMMANDS below).
952 OPTIND The index of the next argument to be processed by the getopts
953 builtin command (see SHELL BUILTIN COMMANDS below).
954 OSTYPE Automatically set to a string that describes the operating sysâ€
955 tem on which bash is executing. The default is system-depenâ€
956 dent.
957 PIPESTATUS
958 An array variable (see Arrays below) containing a list of exit
959 status values from the processes in the most-recently-executed
960 foreground pipeline (which may contain only a single command).
961 PPID The process ID of the shell's parent. This variable is readâ€
962 only.
963 PWD The current working directory as set by the cd command.
964 RANDOM Each time this parameter is referenced, a random integer between
965 0 and 32767 is generated. The sequence of random numbers may be
966 initialized by assigning a value to RANDOM. If RANDOM is unset,
967 it loses its special properties, even if it is subsequently
968 reset.
969 READLINE_LINE
970 The contents of the readline line buffer, for use with "bind -x"
971 (see SHELL BUILTIN COMMANDS below).
972 READLINE_POINT
973 The position of the insertion point in the readline line buffer,
974 for use with "bind -x" (see SHELL BUILTIN COMMANDS below).
975 REPLY Set to the line of input read by the read builtin command when
976 no arguments are supplied.
977 SECONDS
978 Each time this parameter is referenced, the number of seconds
979 since shell invocation is returned. If a value is assigned to
980 SECONDS, the value returned upon subsequent references is the
981 number of seconds since the assignment plus the value assigned.
982 If SECONDS is unset, it loses its special properties, even if it
983 is subsequently reset.
984 SHELLOPTS
985 A colon-separated list of enabled shell options. Each word in
986 the list is a valid argument for the -o option to the set
987 builtin command (see SHELL BUILTIN COMMANDS below). The options
988 appearing in SHELLOPTS are those reported as on by set -o. If
989 this variable is in the environment when bash starts up, each
990 shell option in the list will be enabled before reading any
991 startup files. This variable is read-only.
992 SHLVL Incremented by one each time an instance of bash is started.
993 UID Expands to the user ID of the current user, initialized at shell
994 startup. This variable is readonly.
995
996 The following variables are used by the shell. In some cases, bash
997 assigns a default value to a variable; these cases are noted below.
998
999 BASH_COMPAT
1000 The value is used to set the shell's compatibility level. See
1001 the description of the shopt builtin below under SHELL BUILTIN
1002 COMMANDS for a description of the various compatibility levels
1003 and their effects. The value may be a decimal number (e.g.,
1004 4.2) or an integer (e.g., 42) corresponding to the desired comâ€
1005 patibility level. If BASH_COMPAT is unset or set to the empty
1006 string, the compatibility level is set to the default for the
1007 current version. If BASH_COMPAT is set to a value that is not
1008 one of the valid compatibility levels, the shell prints an error
1009 message and sets the compatibility level to the default for the
1010 current version. The valid compatibility levels correspond to
1011 the compatibility options accepted by the shopt builtin
1012 described below (for example, compat42 means that 4.2 and 42 are
1013 valid values). The current version is also a valid value.
1014 BASH_ENV
1015 If this parameter is set when bash is executing a shell script,
1016 its value is interpreted as a filename containing commands to
1017 initialize the shell, as in ~/.bashrc. The value of BASH_ENV is
1018 subjected to parameter expansion, command substitution, and
1019 arithmetic expansion before being interpreted as a filename.
1020 PATH is not used to search for the resultant filename.
1021 BASH_XTRACEFD
1022 If set to an integer corresponding to a valid file descriptor,
1023 bash will write the trace output generated when set -x is
1024 enabled to that file descriptor. The file descriptor is closed
1025 when BASH_XTRACEFD is unset or assigned a new value. Unsetting
1026 BASH_XTRACEFD or assigning it the empty string causes the trace
1027 output to be sent to the standard error. Note that setting
1028 BASH_XTRACEFD to 2 (the standard error file descriptor) and then
1029 unsetting it will result in the standard error being closed.
1030 CDPATH The search path for the cd command. This is a colon-separated
1031 list of directories in which the shell looks for destination
1032 directories specified by the cd command. A sample value is
1033 ".:~:/usr".
1034 CHILD_MAX
1035 Set the number of exited child status values for the shell to
1036 remember. Bash will not allow this value to be decreased below
1037 a POSIX-mandated minimum, and there is a maximum value (curâ€
1038 rently 8192) that this may not exceed. The minimum value is
1039 system-dependent.
1040 COLUMNS
1041 Used by the select compound command to determine the terminal
1042 width when printing selection lists. Automatically set if the
1043 checkwinsize option is enabled or in an interactive shell upon
1044 receipt of a SIGWINCH.
1045 COMPREPLY
1046 An array variable from which bash reads the possible completions
1047 generated by a shell function invoked by the programmable comâ€
1048 pletion facility (see Programmable Completion below). Each
1049 array element contains one possible completion.
1050 EMACS If bash finds this variable in the environment when the shell
1051 starts with value "t", it assumes that the shell is running in
1052 an Emacs shell buffer and disables line editing.
1053 ENV Similar to BASH_ENV; used when the shell is invoked in POSIX
1054 mode.
1055 FCEDIT The default editor for the fc builtin command.
1056 FIGNORE
1057 A colon-separated list of suffixes to ignore when performing
1058 filename completion (see READLINE below). A filename whose sufâ€
1059 fix matches one of the entries in FIGNORE is excluded from the
1060 list of matched filenames. A sample value is ".o:~".
1061 FUNCNEST
1062 If set to a numeric value greater than 0, defines a maximum
1063 function nesting level. Function invocations that exceed this
1064 nesting level will cause the current command to abort.
1065 GLOBIGNORE
1066 A colon-separated list of patterns defining the set of filenames
1067 to be ignored by pathname expansion. If a filename matched by a
1068 pathname expansion pattern also matches one of the patterns in
1069 GLOBIGNORE, it is removed from the list of matches.
1070 HISTCONTROL
1071 A colon-separated list of values controlling how commands are
1072 saved on the history list. If the list of values includes
1073 ignorespace, lines which begin with a space character are not
1074 saved in the history list. A value of ignoredups causes lines
1075 matching the previous history entry to not be saved. A value of
1076 ignoreboth is shorthand for ignorespace and ignoredups. A value
1077 of erasedups causes all previous lines matching the current line
1078 to be removed from the history list before that line is saved.
1079 Any value not in the above list is ignored. If HISTCONTROL is
1080 unset, or does not include a valid value, all lines read by the
1081 shell parser are saved on the history list, subject to the value
1082 of HISTIGNORE. The second and subsequent lines of a multi-line
1083 compound command are not tested, and are added to the history
1084 regardless of the value of HISTCONTROL.
1085 HISTFILE
1086 The name of the file in which command history is saved (see HISâ€
1087 TORY below). The default value is ~/.bash_history. If unset,
1088 the command history is not saved when a shell exits.
1089 HISTFILESIZE
1090 The maximum number of lines contained in the history file. When
1091 this variable is assigned a value, the history file is trunâ€
1092 cated, if necessary, to contain no more than that number of
1093 lines by removing the oldest entries. The history file is also
1094 truncated to this size after writing it when a shell exits. If
1095 the value is 0, the history file is truncated to zero size.
1096 Non-numeric values and numeric values less than zero inhibit
1097 truncation. The shell sets the default value to the value of
1098 HISTSIZE after reading any startup files.
1099 HISTIGNORE
1100 A colon-separated list of patterns used to decide which command
1101 lines should be saved on the history list. Each pattern is
1102 anchored at the beginning of the line and must match the comâ€
1103 plete line (no implicit `*' is appended). Each pattern is
1104 tested against the line after the checks specified by HISTCONâ€
1105 TROL are applied. In addition to the normal shell pattern
1106 matching characters, `&' matches the previous history line. `&'
1107 may be escaped using a backslash; the backslash is removed
1108 before attempting a match. The second and subsequent lines of a
1109 multi-line compound command are not tested, and are added to the
1110 history regardless of the value of HISTIGNORE.
1111 HISTSIZE
1112 The number of commands to remember in the command history (see
1113 HISTORY below). If the value is 0, commands are not saved in
1114 the history list. Numeric values less than zero result in every
1115 command being saved on the history list (there is no limit).
1116 The shell sets the default value to 500 after reading any
1117 startup files.
1118 HISTTIMEFORMAT
1119 If this variable is set and not null, its value is used as a
1120 format string for strftime(3) to print the time stamp associated
1121 with each history entry displayed by the history builtin. If
1122 this variable is set, time stamps are written to the history
1123 file so they may be preserved across shell sessions. This uses
1124 the history comment character to distinguish timestamps from
1125 other history lines.
1126 HOME The home directory of the current user; the default argument for
1127 the cd builtin command. The value of this variable is also used
1128 when performing tilde expansion.
1129 HOSTFILE
1130 Contains the name of a file in the same format as /etc/hosts
1131 that should be read when the shell needs to complete a hostname.
1132 The list of possible hostname completions may be changed while
1133 the shell is running; the next time hostname completion is
1134 attempted after the value is changed, bash adds the contents of
1135 the new file to the existing list. If HOSTFILE is set, but has
1136 no value, or does not name a readable file, bash attempts to
1137 read /etc/hosts to obtain the list of possible hostname compleâ€
1138 tions. When HOSTFILE is unset, the hostname list is cleared.
1139 IFS The Internal Field Separator that is used for word splitting
1140 after expansion and to split lines into words with the read
1141 builtin command. The default value is ``<space><tab><newâ€
1142 line>''.
1143 IGNOREEOF
1144 Controls the action of an interactive shell on receipt of an EOF
1145 character as the sole input. If set, the value is the number of
1146 consecutive EOF characters which must be typed as the first
1147 characters on an input line before bash exits. If the variable
1148 exists but does not have a numeric value, or has no value, the
1149 default value is 10. If it does not exist, EOF signifies the
1150 end of input to the shell.
1151 INPUTRC
1152 The filename for the readline startup file, overriding the
1153 default of ~/.inputrc (see READLINE below).
1154 LANG Used to determine the locale category for any category not
1155 specifically selected with a variable starting with LC_.
1156 LC_ALL This variable overrides the value of LANG and any other LC_
1157 variable specifying a locale category.
1158 LC_COLLATE
1159 This variable determines the collation order used when sorting
1160 the results of pathname expansion, and determines the behavior
1161 of range expressions, equivalence classes, and collating
1162 sequences within pathname expansion and pattern matching.
1163 LC_CTYPE
1164 This variable determines the interpretation of characters and
1165 the behavior of character classes within pathname expansion and
1166 pattern matching.
1167 LC_MESSAGES
1168 This variable determines the locale used to translate double-
1169 quoted strings preceded by a $.
1170 LC_NUMERIC
1171 This variable determines the locale category used for number
1172 formatting.
1173 LINES Used by the select compound command to determine the column
1174 length for printing selection lists. Automatically set if the
1175 checkwinsize option is enabled or in an interactive shell upon
1176 receipt of a SIGWINCH.
1177 MAIL If this parameter is set to a file or directory name and the
1178 MAILPATH variable is not set, bash informs the user of the
1179 arrival of mail in the specified file or Maildir-format direcâ€
1180 tory.
1181 MAILCHECK
1182 Specifies how often (in seconds) bash checks for mail. The
1183 default is 60 seconds. When it is time to check for mail, the
1184 shell does so before displaying the primary prompt. If this
1185 variable is unset, or set to a value that is not a number
1186 greater than or equal to zero, the shell disables mail checking.
1187 MAILPATH
1188 A colon-separated list of filenames to be checked for mail. The
1189 message to be printed when mail arrives in a particular file may
1190 be specified by separating the filename from the message with a
1191 `?'. When used in the text of the message, $_ expands to the
1192 name of the current mailfile. Example:
1193 MAILPATH='/var/mail/bfox?"You have mail":~/shell-mail?"$_ has
1194 mail!"'
1195 Bash supplies a default value for this variable, but the locaâ€
1196 tion of the user mail files that it uses is system dependent
1197 (e.g., /var/mail/$USER).
1198 OPTERR If set to the value 1, bash displays error messages generated by
1199 the getopts builtin command (see SHELL BUILTIN COMMANDS below).
1200 OPTERR is initialized to 1 each time the shell is invoked or a
1201 shell script is executed.
1202 PATH The search path for commands. It is a colon-separated list of
1203 directories in which the shell looks for commands (see COMMAND
1204 EXECUTION below). A zero-length (null) directory name in the
1205 value of PATH indicates the current directory. A null directory
1206 name may appear as two adjacent colons, or as an initial or
1207 trailing colon. The default path is system-dependent, and is
1208 set by the administrator who installs bash. A common value is
1209 ``/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin''.
1210 POSIXLY_CORRECT
1211 If this variable is in the environment when bash starts, the
1212 shell enters posix mode before reading the startup files, as if
1213 the --posix invocation option had been supplied. If it is set
1214 while the shell is running, bash enables posix mode, as if the
1215 command set -o posix had been executed.
1216 PROMPT_COMMAND
1217 If set, the value is executed as a command prior to issuing each
1218 primary prompt.
1219 PROMPT_DIRTRIM
1220 If set to a number greater than zero, the value is used as the
1221 number of trailing directory components to retain when expanding
1222 the \w and \W prompt string escapes (see PROMPTING below).
1223 Characters removed are replaced with an ellipsis.
1224 PS1 The value of this parameter is expanded (see PROMPTING below)
1225 and used as the primary prompt string. The default value is
1226 ``\s-\v\$ ''.
1227 PS2 The value of this parameter is expanded as with PS1 and used as
1228 the secondary prompt string. The default is ``> ''.
1229 PS3 The value of this parameter is used as the prompt for the select
1230 command (see SHELL GRAMMAR above).
1231 PS4 The value of this parameter is expanded as with PS1 and the
1232 value is printed before each command bash displays during an
1233 execution trace. The first character of PS4 is replicated mulâ€
1234 tiple times, as necessary, to indicate multiple levels of indiâ€
1235 rection. The default is ``+ ''.
1236 SHELL The full pathname to the shell is kept in this environment variâ€
1237 able. If it is not set when the shell starts, bash assigns to
1238 it the full pathname of the current user's login shell.
1239 TIMEFORMAT
1240 The value of this parameter is used as a format string specifyâ€
1241 ing how the timing information for pipelines prefixed with the
1242 time reserved word should be displayed. The % character introâ€
1243 duces an escape sequence that is expanded to a time value or
1244 other information. The escape sequences and their meanings are
1245 as follows; the braces denote optional portions.
1246 %% A literal %.
1247 %[p][l]R The elapsed time in seconds.
1248 %[p][l]U The number of CPU seconds spent in user mode.
1249 %[p][l]S The number of CPU seconds spent in system mode.
1250 %P The CPU percentage, computed as (%U + %S) / %R.
1251
1252 The optional p is a digit specifying the precision, the number
1253 of fractional digits after a decimal point. A value of 0 causes
1254 no decimal point or fraction to be output. At most three places
1255 after the decimal point may be specified; values of p greater
1256 than 3 are changed to 3. If p is not specified, the value 3 is
1257 used.
1258
1259 The optional l specifies a longer format, including minutes, of
1260 the form MMmSS.FFs. The value of p determines whether or not
1261 the fraction is included.
1262
1263 If this variable is not set, bash acts as if it had the value
1264 $'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS'. If the value is null,
1265 no timing information is displayed. A trailing newline is added
1266 when the format string is displayed.
1267 TMOUT If set to a value greater than zero, TMOUT is treated as the
1268 default timeout for the read builtin. The select command termiâ€
1269 nates if input does not arrive after TMOUT seconds when input is
1270 coming from a terminal. In an interactive shell, the value is
1271 interpreted as the number of seconds to wait for a line of input
1272 after issuing the primary prompt. Bash terminates after waiting
1273 for that number of seconds if a complete line of input does not
1274 arrive.
1275 TMPDIR If set, bash uses its value as the name of a directory in which
1276 bash creates temporary files for the shell's use.
1277 auto_resume
1278 This variable controls how the shell interacts with the user and
1279 job control. If this variable is set, single word simple comâ€
1280 mands without redirections are treated as candidates for resumpâ€
1281 tion of an existing stopped job. There is no ambiguity allowed;
1282 if there is more than one job beginning with the string typed,
1283 the job most recently accessed is selected. The name of a
1284 stopped job, in this context, is the command line used to start
1285 it. If set to the value exact, the string supplied must match
1286 the name of a stopped job exactly; if set to substring, the
1287 string supplied needs to match a substring of the name of a
1288 stopped job. The substring value provides functionality analoâ€
1289 gous to the %? job identifier (see JOB CONTROL below). If set
1290 to any other value, the supplied string must be a prefix of a
1291 stopped job's name; this provides functionality analogous to the
1292 %string job identifier.
1293 histchars
1294 The two or three characters which control history expansion and
1295 tokenization (see HISTORY EXPANSION below). The first character
1296 is the history expansion character, the character which signals
1297 the start of a history expansion, normally `!'. The second
1298 character is the quick substitution character, which is used as
1299 shorthand for re-running the previous command entered, substiâ€
1300 tuting one string for another in the command. The default is
1301 `^'. The optional third character is the character which indiâ€
1302 cates that the remainder of the line is a comment when found as
1303 the first character of a word, normally `#'. The history comâ€
1304 ment character causes history substitution to be skipped for the
1305 remaining words on the line. It does not necessarily cause the
1306 shell parser to treat the rest of the line as a comment.
1307
1308 Arrays
1309 Bash provides one-dimensional indexed and associative array variables.
1310 Any variable may be used as an indexed array; the declare builtin will
1311 explicitly declare an array. There is no maximum limit on the size of
1312 an array, nor any requirement that members be indexed or assigned conâ€
1313 tiguously. Indexed arrays are referenced using integers (including
1314 arithmetic expressions) and are zero-based; associative arrays are
1315 referenced using arbitrary strings. Unless otherwise noted, indexed
1316 array indices must be non-negative integers.
1317
1318 An indexed array is created automatically if any variable is assigned
1319 to using the syntax name[subscript]=value. The subscript is treated as
1320 an arithmetic expression that must evaluate to a number. To explicitly
1321 declare an indexed array, use declare -a name (see SHELL BUILTIN COMâ€
1322 MANDS below). declare -a name[subscript] is also accepted; the subâ€
1323 script is ignored.
1324
1325 Associative arrays are created using declare -A name.
1326
1327 Attributes may be specified for an array variable using the declare and
1328 readonly builtins. Each attribute applies to all members of an array.
1329
1330 Arrays are assigned to using compound assignments of the form
1331 name=(value1 ... valuen), where each value is of the form [subâ€
1332 script]=string. Indexed array assignments do not require anything but
1333 string. When assigning to indexed arrays, if the optional brackets and
1334 subscript are supplied, that index is assigned to; otherwise the index
1335 of the element assigned is the last index assigned to by the statement
1336 plus one. Indexing starts at zero.
1337
1338 When assigning to an associative array, the subscript is required.
1339
1340 This syntax is also accepted by the declare builtin. Individual array
1341 elements may be assigned to using the name[subscript]=value syntax
1342 introduced above. When assigning to an indexed array, if name is subâ€
1343 scripted by a negative number, that number is interpreted as relative
1344 to one greater than the maximum index of name, so negative indices
1345 count back from the end of the array, and an index of -1 references the
1346 last element.
1347
1348 Any element of an array may be referenced using ${name[subscript]}.
1349 The braces are required to avoid conflicts with pathname expansion. If
1350 subscript is @ or *, the word expands to all members of name. These
1351 subscripts differ only when the word appears within double quotes. If
1352 the word is double-quoted, ${name[*]} expands to a single word with the
1353 value of each array member separated by the first character of the IFS
1354 special variable, and ${name[@]} expands each element of name to a sepâ€
1355 arate word. When there are no array members, ${name[@]} expands to
1356 nothing. If the double-quoted expansion occurs within a word, the
1357 expansion of the first parameter is joined with the beginning part of
1358 the original word, and the expansion of the last parameter is joined
1359 with the last part of the original word. This is analogous to the
1360 expansion of the special parameters * and @ (see Special Parameters
1361 above). ${#name[subscript]} expands to the length of ${name[subâ€
1362 script]}. If subscript is * or @, the expansion is the number of eleâ€
1363 ments in the array. Referencing an array variable without a subscript
1364 is equivalent to referencing the array with a subscript of 0. If the
1365 subscript used to reference an element of an indexed array evaluates to
1366 a number less than zero, it is interpreted as relative to one greater
1367 than the maximum index of the array, so negative indices count back
1368 from the end of the array, and an index of -1 references the last eleâ€
1369 ment.
1370
1371 An array variable is considered set if a subscript has been assigned a
1372 value. The null string is a valid value.
1373
1374 It is possible to obtain the keys (indices) of an array as well as the
1375 values. ${!name[@]} and ${!name[*]} expand to the indices assigned in
1376 array variable name. The treatment when in double quotes is similar to
1377 the expansion of the special parameters @ and * within double quotes.
1378
1379 The unset builtin is used to destroy arrays. unset name[subscript]
1380 destroys the array element at index subscript. Negative subscripts to
1381 indexed arrays are interpreted as described above. Care must be taken
1382 to avoid unwanted side effects caused by pathname expansion. unset
1383 name, where name is an array, or unset name[subscript], where subscript
1384 is * or @, removes the entire array.
1385
1386 The declare, local, and readonly builtins each accept a -a option to
1387 specify an indexed array and a -A option to specify an associative
1388 array. If both options are supplied, -A takes precedence. The read
1389 builtin accepts a -a option to assign a list of words read from the
1390 standard input to an array. The set and declare builtins display array
1391 values in a way that allows them to be reused as assignments.
1392
1393EXPANSION
1394 Expansion is performed on the command line after it has been split into
1395 words. There are seven kinds of expansion performed: brace expansion,
1396 tilde expansion, parameter and variable expansion, command substituâ€
1397 tion, arithmetic expansion, word splitting, and pathname expansion.
1398
1399 The order of expansions is: brace expansion; tilde expansion, parameter
1400 and variable expansion, arithmetic expansion, and command substitution
1401 (done in a left-to-right fashion); word splitting; and pathname expanâ€
1402 sion.
1403
1404 On systems that can support it, there is an additional expansion availâ€
1405 able: process substitution. This is performed at the same time as
1406 tilde, parameter, variable, and arithmetic expansion and command subâ€
1407 stitution.
1408
1409 Only brace expansion, word splitting, and pathname expansion can change
1410 the number of words of the expansion; other expansions expand a single
1411 word to a single word. The only exceptions to this are the expansions
1412 of "$@" and "${name[@]}" as explained above (see PARAMETERS).
1413
1414 Brace Expansion
1415 Brace expansion is a mechanism by which arbitrary strings may be generâ€
1416 ated. This mechanism is similar to pathname expansion, but the fileâ€
1417 names generated need not exist. Patterns to be brace expanded take the
1418 form of an optional preamble, followed by either a series of comma-sepâ€
1419 arated strings or a sequence expression between a pair of braces, folâ€
1420 lowed by an optional postscript. The preamble is prefixed to each
1421 string contained within the braces, and the postscript is then appended
1422 to each resulting string, expanding left to right.
1423
1424 Brace expansions may be nested. The results of each expanded string
1425 are not sorted; left to right order is preserved. For example,
1426 a{d,c,b}e expands into `ade ace abe'.
1427
1428 A sequence expression takes the form {x..y[..incr]}, where x and y are
1429 either integers or single characters, and incr, an optional increment,
1430 is an integer. When integers are supplied, the expression expands to
1431 each number between x and y, inclusive. Supplied integers may be preâ€
1432 fixed with 0 to force each term to have the same width. When either x
1433 or y begins with a zero, the shell attempts to force all generated
1434 terms to contain the same number of digits, zero-padding where necesâ€
1435 sary. When characters are supplied, the expression expands to each
1436 character lexicographically between x and y, inclusive, using the
1437 default C locale. Note that both x and y must be of the same type.
1438 When the increment is supplied, it is used as the difference between
1439 each term. The default increment is 1 or -1 as appropriate.
1440
1441 Brace expansion is performed before any other expansions, and any charâ€
1442 acters special to other expansions are preserved in the result. It is
1443 strictly textual. Bash does not apply any syntactic interpretation to
1444 the context of the expansion or the text between the braces.
1445
1446 A correctly-formed brace expansion must contain unquoted opening and
1447 closing braces, and at least one unquoted comma or a valid sequence
1448 expression. Any incorrectly formed brace expansion is left unchanged.
1449 A { or , may be quoted with a backslash to prevent its being considered
1450 part of a brace expression. To avoid conflicts with parameter expanâ€
1451 sion, the string ${ is not considered eligible for brace expansion.
1452
1453 This construct is typically used as shorthand when the common prefix of
1454 the strings to be generated is longer than in the above example:
1455
1456 mkdir /usr/local/src/bash/{old,new,dist,bugs}
1457 or
1458 chown root /usr/{ucb/{ex,edit},lib/{ex?.?*,how_ex}}
1459
1460 Brace expansion introduces a slight incompatibility with historical
1461 versions of sh. sh does not treat opening or closing braces specially
1462 when they appear as part of a word, and preserves them in the output.
1463 Bash removes braces from words as a consequence of brace expansion.
1464 For example, a word entered to sh as file{1,2} appears identically in
1465 the output. The same word is output as file1 file2 after expansion by
1466 bash. If strict compatibility with sh is desired, start bash with the
1467 +B option or disable brace expansion with the +B option to the set comâ€
1468 mand (see SHELL BUILTIN COMMANDS below).
1469
1470 Tilde Expansion
1471 If a word begins with an unquoted tilde character (`~'), all of the
1472 characters preceding the first unquoted slash (or all characters, if
1473 there is no unquoted slash) are considered a tilde-prefix. If none of
1474 the characters in the tilde-prefix are quoted, the characters in the
1475 tilde-prefix following the tilde are treated as a possible login name.
1476 If this login name is the null string, the tilde is replaced with the
1477 value of the shell parameter HOME. If HOME is unset, the home direcâ€
1478 tory of the user executing the shell is substituted instead. Otherâ€
1479 wise, the tilde-prefix is replaced with the home directory associated
1480 with the specified login name.
1481
1482 If the tilde-prefix is a `~+', the value of the shell variable PWD
1483 replaces the tilde-prefix. If the tilde-prefix is a `~-', the value of
1484 the shell variable OLDPWD, if it is set, is substituted. If the charâ€
1485 acters following the tilde in the tilde-prefix consist of a number N,
1486 optionally prefixed by a `+' or a `-', the tilde-prefix is replaced
1487 with the corresponding element from the directory stack, as it would be
1488 displayed by the dirs builtin invoked with the tilde-prefix as an arguâ€
1489 ment. If the characters following the tilde in the tilde-prefix conâ€
1490 sist of a number without a leading `+' or `-', `+' is assumed.
1491
1492 If the login name is invalid, or the tilde expansion fails, the word is
1493 unchanged.
1494
1495 Each variable assignment is checked for unquoted tilde-prefixes immediâ€
1496 ately following a : or the first =. In these cases, tilde expansion is
1497 also performed. Consequently, one may use filenames with tildes in
1498 assignments to PATH, MAILPATH, and CDPATH, and the shell assigns the
1499 expanded value.
1500
1501 Parameter Expansion
1502 The `$' character introduces parameter expansion, command substitution,
1503 or arithmetic expansion. The parameter name or symbol to be expanded
1504 may be enclosed in braces, which are optional but serve to protect the
1505 variable to be expanded from characters immediately following it which
1506 could be interpreted as part of the name.
1507
1508 When braces are used, the matching ending brace is the first `}' not
1509 escaped by a backslash or within a quoted string, and not within an
1510 embedded arithmetic expansion, command substitution, or parameter
1511 expansion.
1512
1513 ${parameter}
1514 The value of parameter is substituted. The braces are required
1515 when parameter is a positional parameter with more than one
1516 digit, or when parameter is followed by a character which is not
1517 to be interpreted as part of its name. The parameter is a shell
1518 parameter as described above PARAMETERS) or an array reference
1519 (Arrays).
1520
1521 If the first character of parameter is an exclamation point (!), it
1522 introduces a level of variable indirection. Bash uses the value of the
1523 variable formed from the rest of parameter as the name of the variable;
1524 this variable is then expanded and that value is used in the rest of
1525 the substitution, rather than the value of parameter itself. This is
1526 known as indirect expansion. The exceptions to this are the expansions
1527 of ${!prefix*} and ${!name[@]} described below. The exclamation point
1528 must immediately follow the left brace in order to introduce indirecâ€
1529 tion.
1530
1531 In each of the cases below, word is subject to tilde expansion, parameâ€
1532 ter expansion, command substitution, and arithmetic expansion.
1533
1534 When not performing substring expansion, using the forms documented
1535 below (e.g., :-), bash tests for a parameter that is unset or null.
1536 Omitting the colon results in a test only for a parameter that is
1537 unset.
1538
1539 ${parameter:-word}
1540 Use Default Values. If parameter is unset or null, the expanâ€
1541 sion of word is substituted. Otherwise, the value of parameter
1542 is substituted.
1543 ${parameter:=word}
1544 Assign Default Values. If parameter is unset or null, the
1545 expansion of word is assigned to parameter. The value of paramâ€
1546 eter is then substituted. Positional parameters and special
1547 parameters may not be assigned to in this way.
1548 ${parameter:?word}
1549 Display Error if Null or Unset. If parameter is null or unset,
1550 the expansion of word (or a message to that effect if word is
1551 not present) is written to the standard error and the shell, if
1552 it is not interactive, exits. Otherwise, the value of parameter
1553 is substituted.
1554 ${parameter:+word}
1555 Use Alternate Value. If parameter is null or unset, nothing is
1556 substituted, otherwise the expansion of word is substituted.
1557 ${parameter:offset}
1558 ${parameter:offset:length}
1559 Substring Expansion. Expands to up to length characters of the
1560 value of parameter starting at the character specified by offâ€
1561 set. If parameter is @, an indexed array subscripted by @ or *,
1562 or an associative array name, the results differ as described
1563 below. If length is omitted, expands to the substring of the
1564 value of parameter starting at the character specified by offset
1565 and extending to the end of the value. length and offset are
1566 arithmetic expressions (see ARITHMETIC EVALUATION below).
1567
1568 If offset evaluates to a number less than zero, the value is
1569 used as an offset in characters from the end of the value of
1570 parameter. If length evaluates to a number less than zero, it
1571 is interpreted as an offset in characters from the end of the
1572 value of parameter rather than a number of characters, and the
1573 expansion is the characters between offset and that result.
1574 Note that a negative offset must be separated from the colon by
1575 at least one space to avoid being confused with the :- expanâ€
1576 sion.
1577
1578 If parameter is @, the result is length positional parameters
1579 beginning at offset. A negative offset is taken relative to one
1580 greater than the greatest positional parameter, so an offset of
1581 -1 evaluates to the last positional parameter. It is an expanâ€
1582 sion error if length evaluates to a number less than zero.
1583
1584 If parameter is an indexed array name subscripted by @ or *, the
1585 result is the length members of the array beginning with
1586 ${parameter[offset]}. A negative offset is taken relative to
1587 one greater than the maximum index of the specified array. It
1588 is an expansion error if length evaluates to a number less than
1589 zero.
1590
1591 Substring expansion applied to an associative array produces
1592 undefined results.
1593
1594 Substring indexing is zero-based unless the positional parameâ€
1595 ters are used, in which case the indexing starts at 1 by
1596 default. If offset is 0, and the positional parameters are
1597 used, $0 is prefixed to the list.
1598
1599 ${!prefix*}
1600 ${!prefix@}
1601 Names matching prefix. Expands to the names of variables whose
1602 names begin with prefix, separated by the first character of the
1603 IFS special variable. When @ is used and the expansion appears
1604 within double quotes, each variable name expands to a separate
1605 word.
1606
1607 ${!name[@]}
1608 ${!name[*]}
1609 List of array keys. If name is an array variable, expands to
1610 the list of array indices (keys) assigned in name. If name is
1611 not an array, expands to 0 if name is set and null otherwise.
1612 When @ is used and the expansion appears within double quotes,
1613 each key expands to a separate word.
1614
1615 ${#parameter}
1616 Parameter length. The length in characters of the value of
1617 parameter is substituted. If parameter is * or @, the value
1618 substituted is the number of positional parameters. If parameâ€
1619 ter is an array name subscripted by * or @, the value substiâ€
1620 tuted is the number of elements in the array. If parameter is
1621 an indexed array name subscripted by a negative number, that
1622 number is interpreted as relative to one greater than the maxiâ€
1623 mum index of parameter, so negative indices count back from the
1624 end of the array, and an index of -1 references the last eleâ€
1625 ment.
1626
1627 ${parameter#word}
1628 ${parameter##word}
1629 Remove matching prefix pattern. The word is expanded to produce
1630 a pattern just as in pathname expansion. If the pattern matches
1631 the beginning of the value of parameter, then the result of the
1632 expansion is the expanded value of parameter with the shortest
1633 matching pattern (the ``#'' case) or the longest matching patâ€
1634 tern (the ``##'' case) deleted. If parameter is @ or *, the
1635 pattern removal operation is applied to each positional parameâ€
1636 ter in turn, and the expansion is the resultant list. If paramâ€
1637 eter is an array variable subscripted with @ or *, the pattern
1638 removal operation is applied to each member of the array in
1639 turn, and the expansion is the resultant list.
1640
1641 ${parameter%word}
1642 ${parameter%%word}
1643 Remove matching suffix pattern. The word is expanded to produce
1644 a pattern just as in pathname expansion. If the pattern matches
1645 a trailing portion of the expanded value of parameter, then the
1646 result of the expansion is the expanded value of parameter with
1647 the shortest matching pattern (the ``%'' case) or the longest
1648 matching pattern (the ``%%'' case) deleted. If parameter is @
1649 or *, the pattern removal operation is applied to each posiâ€
1650 tional parameter in turn, and the expansion is the resultant
1651 list. If parameter is an array variable subscripted with @ or
1652 *, the pattern removal operation is applied to each member of
1653 the array in turn, and the expansion is the resultant list.
1654
1655 ${parameter/pattern/string}
1656 Pattern substitution. The pattern is expanded to produce a patâ€
1657 tern just as in pathname expansion. Parameter is expanded and
1658 the longest match of pattern against its value is replaced with
1659 string. If pattern begins with /, all matches of pattern are
1660 replaced with string. Normally only the first match is
1661 replaced. If pattern begins with #, it must match at the beginâ€
1662 ning of the expanded value of parameter. If pattern begins with
1663 %, it must match at the end of the expanded value of parameter.
1664 If string is null, matches of pattern are deleted and the / folâ€
1665 lowing pattern may be omitted. If parameter is @ or *, the subâ€
1666 stitution operation is applied to each positional parameter in
1667 turn, and the expansion is the resultant list. If parameter is
1668 an array variable subscripted with @ or *, the substitution
1669 operation is applied to each member of the array in turn, and
1670 the expansion is the resultant list.
1671
1672 ${parameter^pattern}
1673 ${parameter^^pattern}
1674 ${parameter,pattern}
1675 ${parameter,,pattern}
1676 Case modification. This expansion modifies the case of alphaâ€
1677 betic characters in parameter. The pattern is expanded to proâ€
1678 duce a pattern just as in pathname expansion. Each character in
1679 the expanded value of parameter is tested against pattern, and,
1680 if it matches the pattern, its case is converted. The pattern
1681 should not attempt to match more than one character. The ^
1682 operator converts lowercase letters matching pattern to upperâ€
1683 case; the , operator converts matching uppercase letters to lowâ€
1684 ercase. The ^^ and ,, expansions convert each matched character
1685 in the expanded value; the ^ and , expansions match and convert
1686 only the first character in the expanded value. If pattern is
1687 omitted, it is treated like a ?, which matches every character.
1688 If parameter is @ or *, the case modification operation is
1689 applied to each positional parameter in turn, and the expansion
1690 is the resultant list. If parameter is an array variable subâ€
1691 scripted with @ or *, the case modification operation is applied
1692 to each member of the array in turn, and the expansion is the
1693 resultant list.
1694
1695 Command Substitution
1696 Command substitution allows the output of a command to replace the comâ€
1697 mand name. There are two forms:
1698
1699 $(command)
1700 or
1701 `command`
1702
1703 Bash performs the expansion by executing command and replacing the comâ€
1704 mand substitution with the standard output of the command, with any
1705 trailing newlines deleted. Embedded newlines are not deleted, but they
1706 may be removed during word splitting. The command substitution $(cat
1707 file) can be replaced by the equivalent but faster $(< file).
1708
1709 When the old-style backquote form of substitution is used, backslash
1710 retains its literal meaning except when followed by $, `, or \. The
1711 first backquote not preceded by a backslash terminates the command subâ€
1712 stitution. When using the $(command) form, all characters between the
1713 parentheses make up the command; none are treated specially.
1714
1715 Command substitutions may be nested. To nest when using the backquoted
1716 form, escape the inner backquotes with backslashes.
1717
1718 If the substitution appears within double quotes, word splitting and
1719 pathname expansion are not performed on the results.
1720
1721 Arithmetic Expansion
1722 Arithmetic expansion allows the evaluation of an arithmetic expression
1723 and the substitution of the result. The format for arithmetic expanâ€
1724 sion is:
1725
1726 $((expression))
1727
1728 The expression is treated as if it were within double quotes, but a
1729 double quote inside the parentheses is not treated specially. All
1730 tokens in the expression undergo parameter and variable expansion, comâ€
1731 mand substitution, and quote removal. The result is treated as the
1732 arithmetic expression to be evaluated. Arithmetic expansions may be
1733 nested.
1734
1735 The evaluation is performed according to the rules listed below under
1736 ARITHMETIC EVALUATION. If expression is invalid, bash prints a message
1737 indicating failure and no substitution occurs.
1738
1739 Process Substitution
1740 Process substitution is supported on systems that support named pipes
1741 (FIFOs) or the /dev/fd method of naming open files. It takes the form
1742 of <(list) or >(list). The process list is run with its input or outâ€
1743 put connected to a FIFO or some file in /dev/fd. The name of this file
1744 is passed as an argument to the current command as the result of the
1745 expansion. If the >(list) form is used, writing to the file will proâ€
1746 vide input for list. If the <(list) form is used, the file passed as
1747 an argument should be read to obtain the output of list.
1748
1749 When available, process substitution is performed simultaneously with
1750 parameter and variable expansion, command substitution, and arithmetic
1751 expansion.
1752
1753 Word Splitting
1754 The shell scans the results of parameter expansion, command substituâ€
1755 tion, and arithmetic expansion that did not occur within double quotes
1756 for word splitting.
1757
1758 The shell treats each character of IFS as a delimiter, and splits the
1759 results of the other expansions into words using these characters as
1760 field terminators. If IFS is unset, or its value is exactly
1761 <space><tab><newline>, the default, then sequences of <space>, <tab>,
1762 and <newline> at the beginning and end of the results of the previous
1763 expansions are ignored, and any sequence of IFS characters not at the
1764 beginning or end serves to delimit words. If IFS has a value other
1765 than the default, then sequences of the whitespace characters space and
1766 tab are ignored at the beginning and end of the word, as long as the
1767 whitespace character is in the value of IFS (an IFS whitespace characâ€
1768 ter). Any character in IFS that is not IFS whitespace, along with any
1769 adjacent IFS whitespace characters, delimits a field. A sequence of
1770 IFS whitespace characters is also treated as a delimiter. If the value
1771 of IFS is null, no word splitting occurs.
1772
1773 Explicit null arguments ("" or '') are retained. Unquoted implicit
1774 null arguments, resulting from the expansion of parameters that have no
1775 values, are removed. If a parameter with no value is expanded within
1776 double quotes, a null argument results and is retained.
1777
1778 Note that if no expansion occurs, no splitting is performed.
1779
1780 Pathname Expansion
1781 After word splitting, unless the -f option has been set, bash scans
1782 each word for the characters *, ?, and [. If one of these characters
1783 appears, then the word is regarded as a pattern, and replaced with an
1784 alphabetically sorted list of filenames matching the pattern (see Patâ€
1785 tern Matching below). If no matching filenames are found, and the
1786 shell option nullglob is not enabled, the word is left unchanged. If
1787 the nullglob option is set, and no matches are found, the word is
1788 removed. If the failglob shell option is set, and no matches are
1789 found, an error message is printed and the command is not executed. If
1790 the shell option nocaseglob is enabled, the match is performed without
1791 regard to the case of alphabetic characters. When a pattern is used
1792 for pathname expansion, the character ``.'' at the start of a name or
1793 immediately following a slash must be matched explicitly, unless the
1794 shell option dotglob is set. When matching a pathname, the slash charâ€
1795 acter must always be matched explicitly. In other cases, the ``.''
1796 character is not treated specially. See the description of shopt below
1797 under SHELL BUILTIN COMMANDS for a description of the nocaseglob, nullâ€
1798 glob, failglob, and dotglob shell options.
1799
1800 The GLOBIGNORE shell variable may be used to restrict the set of fileâ€
1801 names matching a pattern. If GLOBIGNORE is set, each matching filename
1802 that also matches one of the patterns in GLOBIGNORE is removed from the
1803 list of matches. The filenames ``.'' and ``..'' are always ignored
1804 when GLOBIGNORE is set and not null. However, setting GLOBIGNORE to a
1805 non-null value has the effect of enabling the dotglob shell option, so
1806 all other filenames beginning with a ``.'' will match. To get the old
1807 behavior of ignoring filenames beginning with a ``.'', make ``.*'' one
1808 of the patterns in GLOBIGNORE. The dotglob option is disabled when
1809 GLOBIGNORE is unset.
1810
1811 Pattern Matching
1812
1813 Any character that appears in a pattern, other than the special pattern
1814 characters described below, matches itself. The NUL character may not
1815 occur in a pattern. A backslash escapes the following character; the
1816 escaping backslash is discarded when matching. The special pattern
1817 characters must be quoted if they are to be matched literally.
1818
1819 The special pattern characters have the following meanings:
1820
1821 * Matches any string, including the null string. When the
1822 globstar shell option is enabled, and * is used in a
1823 pathname expansion context, two adjacent *s used as a
1824 single pattern will match all files and zero or more
1825 directories and subdirectories. If followed by a /, two
1826 adjacent *s will match only directories and subdirectoâ€
1827 ries.
1828 ? Matches any single character.
1829 [...] Matches any one of the enclosed characters. A pair of
1830 characters separated by a hyphen denotes a range expresâ€
1831 sion; any character that falls between those two characâ€
1832 ters, inclusive, using the current locale's collating
1833 sequence and character set, is matched. If the first
1834 character following the [ is a ! or a ^ then any characâ€
1835 ter not enclosed is matched. The sorting order of charâ€
1836 acters in range expressions is determined by the current
1837 locale and the values of the LC_COLLATE or LC_ALL shell
1838 variables, if set. To obtain the traditional interpretaâ€
1839 tion of range expressions, where [a-d] is equivalent to
1840 [abcd], set value of the LC_ALL shell variable to C, or
1841 enable the globasciiranges shell option. A - may be
1842 matched by including it as the first or last character in
1843 the set. A ] may be matched by including it as the first
1844 character in the set.
1845
1846 Within [ and ], character classes can be specified using
1847 the syntax [:class:], where class is one of the following
1848 classes defined in the POSIX standard:
1849 alnum alpha ascii blank cntrl digit graph lower print
1850 punct space upper word xdigit
1851 A character class matches any character belonging to that
1852 class. The word character class matches letters, digits,
1853 and the character _.
1854
1855 Within [ and ], an equivalence class can be specified
1856 using the syntax [=c=], which matches all characters with
1857 the same collation weight (as defined by the current
1858 locale) as the character c.
1859
1860 Within [ and ], the syntax [.symbol.] matches the collatâ€
1861 ing symbol symbol.
1862
1863 If the extglob shell option is enabled using the shopt builtin, several
1864 extended pattern matching operators are recognized. In the following
1865 description, a pattern-list is a list of one or more patterns separated
1866 by a |. Composite patterns may be formed using one or more of the folâ€
1867 lowing sub-patterns:
1868
1869 ?(pattern-list)
1870 Matches zero or one occurrence of the given patterns
1871 *(pattern-list)
1872 Matches zero or more occurrences of the given patterns
1873 +(pattern-list)
1874 Matches one or more occurrences of the given patterns
1875 @(pattern-list)
1876 Matches one of the given patterns
1877 !(pattern-list)
1878 Matches anything except one of the given patterns
1879
1880 Quote Removal
1881 After the preceding expansions, all unquoted occurrences of the characâ€
1882 ters \, ', and " that did not result from one of the above expansions
1883 are removed.
1884
1885REDIRECTION
1886 Before a command is executed, its input and output may be redirected
1887 using a special notation interpreted by the shell. Redirection allows
1888 commands' file handles to be duplicated, opened, closed, made to refer
1889 to different files, and can change the files the command reads from and
1890 writes to. Redirection may also be used to modify file handles in the
1891 current shell execution environment. The following redirection operaâ€
1892 tors may precede or appear anywhere within a simple command or may folâ€
1893 low a command. Redirections are processed in the order they appear,
1894 from left to right.
1895
1896 Each redirection that may be preceded by a file descriptor number may
1897 instead be preceded by a word of the form {varname}. In this case, for
1898 each redirection operator except >&- and <&-, the shell will allocate a
1899 file descriptor greater than or equal to 10 and assign it to varname.
1900 If >&- or <&- is preceded by {varname}, the value of varname defines
1901 the file descriptor to close.
1902
1903 In the following descriptions, if the file descriptor number is omitâ€
1904 ted, and the first character of the redirection operator is <, the reâ€
1905 direction refers to the standard input (file descriptor 0). If the
1906 first character of the redirection operator is >, the redirection
1907 refers to the standard output (file descriptor 1).
1908
1909 The word following the redirection operator in the following descripâ€
1910 tions, unless otherwise noted, is subjected to brace expansion, tilde
1911 expansion, parameter and variable expansion, command substitution,
1912 arithmetic expansion, quote removal, pathname expansion, and word
1913 splitting. If it expands to more than one word, bash reports an error.
1914
1915 Note that the order of redirections is significant. For example, the
1916 command
1917
1918 ls > dirlist 2>&1
1919
1920 directs both standard output and standard error to the file dirlist,
1921 while the command
1922
1923 ls 2>&1 > dirlist
1924
1925 directs only the standard output to file dirlist, because the standard
1926 error was duplicated from the standard output before the standard outâ€
1927 put was redirected to dirlist.
1928
1929 Bash handles several filenames specially when they are used in redirecâ€
1930 tions, as described in the following table:
1931
1932 /dev/fd/fd
1933 If fd is a valid integer, file descriptor fd is dupliâ€
1934 cated.
1935 /dev/stdin
1936 File descriptor 0 is duplicated.
1937 /dev/stdout
1938 File descriptor 1 is duplicated.
1939 /dev/stderr
1940 File descriptor 2 is duplicated.
1941 /dev/tcp/host/port
1942 If host is a valid hostname or Internet address, and port
1943 is an integer port number or service name, bash attempts
1944 to open the corresponding TCP socket.
1945 /dev/udp/host/port
1946 If host is a valid hostname or Internet address, and port
1947 is an integer port number or service name, bash attempts
1948 to open the corresponding UDP socket.
1949
1950 A failure to open or create a file causes the redirection to fail.
1951
1952 Redirections using file descriptors greater than 9 should be used with
1953 care, as they may conflict with file descriptors the shell uses interâ€
1954 nally.
1955
1956 Redirecting Input
1957 Redirection of input causes the file whose name results from the expanâ€
1958 sion of word to be opened for reading on file descriptor n, or the
1959 standard input (file descriptor 0) if n is not specified.
1960
1961 The general format for redirecting input is:
1962
1963 [n]<word
1964
1965 Redirecting Output
1966 Redirection of output causes the file whose name results from the
1967 expansion of word to be opened for writing on file descriptor n, or the
1968 standard output (file descriptor 1) if n is not specified. If the file
1969 does not exist it is created; if it does exist it is truncated to zero
1970 size.
1971
1972 The general format for redirecting output is:
1973
1974 [n]>word
1975
1976 If the redirection operator is >, and the noclobber option to the set
1977 builtin has been enabled, the redirection will fail if the file whose
1978 name results from the expansion of word exists and is a regular file.
1979 If the redirection operator is >|, or the redirection operator is > and
1980 the noclobber option to the set builtin command is not enabled, the reâ€
1981 direction is attempted even if the file named by word exists.
1982
1983 Appending Redirected Output
1984 Redirection of output in this fashion causes the file whose name
1985 results from the expansion of word to be opened for appending on file
1986 descriptor n, or the standard output (file descriptor 1) if n is not
1987 specified. If the file does not exist it is created.
1988
1989 The general format for appending output is:
1990
1991 [n]>>word
1992
1993 Redirecting Standard Output and Standard Error
1994 This construct allows both the standard output (file descriptor 1) and
1995 the standard error output (file descriptor 2) to be redirected to the
1996 file whose name is the expansion of word.
1997
1998 There are two formats for redirecting standard output and standard
1999 error:
2000
2001 &>word
2002 and
2003 >&word
2004
2005 Of the two forms, the first is preferred. This is semantically equivaâ€
2006 lent to
2007
2008 >word 2>&1
2009
2010 When using the second form, word may not expand to a number or -. If
2011 it does, other redirection operators apply (see Duplicating File
2012 Descriptors below) for compatibility reasons.
2013
2014 Appending Standard Output and Standard Error
2015 This construct allows both the standard output (file descriptor 1) and
2016 the standard error output (file descriptor 2) to be appended to the
2017 file whose name is the expansion of word.
2018
2019 The format for appending standard output and standard error is:
2020
2021 &>>word
2022
2023 This is semantically equivalent to
2024
2025 >>word 2>&1
2026
2027 (see Duplicating File Descriptors below).
2028
2029 Here Documents
2030 This type of redirection instructs the shell to read input from the
2031 current source until a line containing only delimiter (with no trailing
2032 blanks) is seen. All of the lines read up to that point are then used
2033 as the standard input for a command.
2034
2035 The format of here-documents is:
2036
2037 <<[-]word
2038 here-document
2039 delimiter
2040
2041 No parameter and variable expansion, command substitution, arithmetic
2042 expansion, or pathname expansion is performed on word. If any characâ€
2043 ters in word are quoted, the delimiter is the result of quote removal
2044 on word, and the lines in the here-document are not expanded. If word
2045 is unquoted, all lines of the here-document are subjected to parameter
2046 expansion, command substitution, and arithmetic expansion, the characâ€
2047 ter sequence \<newline> is ignored, and \ must be used to quote the
2048 characters \, $, and `.
2049
2050 If the redirection operator is <<-, then all leading tab characters are
2051 stripped from input lines and the line containing delimiter. This
2052 allows here-documents within shell scripts to be indented in a natural
2053 fashion.
2054
2055 Here Strings
2056 A variant of here documents, the format is:
2057
2058 <<<word
2059
2060 The word undergoes brace expansion, tilde expansion, parameter and
2061 variable expansion, command substitution, arithmetic expansion, and
2062 quote removal. Pathname expansion and word splitting are not perâ€
2063 formed. The result is supplied as a single string to the command on
2064 its standard input.
2065
2066 Duplicating File Descriptors
2067 The redirection operator
2068
2069 [n]<&word
2070
2071 is used to duplicate input file descriptors. If word expands to one or
2072 more digits, the file descriptor denoted by n is made to be a copy of
2073 that file descriptor. If the digits in word do not specify a file
2074 descriptor open for input, a redirection error occurs. If word evaluâ€
2075 ates to -, file descriptor n is closed. If n is not specified, the
2076 standard input (file descriptor 0) is used.
2077
2078 The operator
2079
2080 [n]>&word
2081
2082 is used similarly to duplicate output file descriptors. If n is not
2083 specified, the standard output (file descriptor 1) is used. If the
2084 digits in word do not specify a file descriptor open for output, a reâ€
2085 direction error occurs. If word evaluates to -, file descriptor n is
2086 closed. As a special case, if n is omitted, and word does not expand
2087 to one or more digits or -, the standard output and standard error are
2088 redirected as described previously.
2089
2090 Moving File Descriptors
2091 The redirection operator
2092
2093 [n]<&digit-
2094
2095 moves the file descriptor digit to file descriptor n, or the standard
2096 input (file descriptor 0) if n is not specified. digit is closed after
2097 being duplicated to n.
2098
2099 Similarly, the redirection operator
2100
2101 [n]>&digit-
2102
2103 moves the file descriptor digit to file descriptor n, or the standard
2104 output (file descriptor 1) if n is not specified.
2105
2106 Opening File Descriptors for Reading and Writing
2107 The redirection operator
2108
2109 [n]<>word
2110
2111 causes the file whose name is the expansion of word to be opened for
2112 both reading and writing on file descriptor n, or on file descriptor 0
2113 if n is not specified. If the file does not exist, it is created.
2114
2115ALIASES
2116 Aliases allow a string to be substituted for a word when it is used as
2117 the first word of a simple command. The shell maintains a list of
2118 aliases that may be set and unset with the alias and unalias builtin
2119 commands (see SHELL BUILTIN COMMANDS below). The first word of each
2120 simple command, if unquoted, is checked to see if it has an alias. If
2121 so, that word is replaced by the text of the alias. The characters /,
2122 $, `, and = and any of the shell metacharacters or quoting characters
2123 listed above may not appear in an alias name. The replacement text may
2124 contain any valid shell input, including shell metacharacters. The
2125 first word of the replacement text is tested for aliases, but a word
2126 that is identical to an alias being expanded is not expanded a second
2127 time. This means that one may alias ls to ls -F, for instance, and
2128 bash does not try to recursively expand the replacement text. If the
2129 last character of the alias value is a blank, then the next command
2130 word following the alias is also checked for alias expansion.
2131
2132 Aliases are created and listed with the alias command, and removed with
2133 the unalias command.
2134
2135 There is no mechanism for using arguments in the replacement text. If
2136 arguments are needed, a shell function should be used (see FUNCTIONS
2137 below).
2138
2139 Aliases are not expanded when the shell is not interactive, unless the
2140 expand_aliases shell option is set using shopt (see the description of
2141 shopt under SHELL BUILTIN COMMANDS below).
2142
2143 The rules concerning the definition and use of aliases are somewhat
2144 confusing. Bash always reads at least one complete line of input
2145 before executing any of the commands on that line. Aliases are
2146 expanded when a command is read, not when it is executed. Therefore,
2147 an alias definition appearing on the same line as another command does
2148 not take effect until the next line of input is read. The commands
2149 following the alias definition on that line are not affected by the new
2150 alias. This behavior is also an issue when functions are executed.
2151 Aliases are expanded when a function definition is read, not when the
2152 function is executed, because a function definition is itself a comâ€
2153 pound command. As a consequence, aliases defined in a function are not
2154 available until after that function is executed. To be safe, always
2155 put alias definitions on a separate line, and do not use alias in comâ€
2156 pound commands.
2157
2158 For almost every purpose, aliases are superseded by shell functions.
2159
2160FUNCTIONS
2161 A shell function, defined as described above under SHELL GRAMMAR,
2162 stores a series of commands for later execution. When the name of a
2163 shell function is used as a simple command name, the list of commands
2164 associated with that function name is executed. Functions are executed
2165 in the context of the current shell; no new process is created to
2166 interpret them (contrast this with the execution of a shell script).
2167 When a function is executed, the arguments to the function become the
2168 positional parameters during its execution. The special parameter # is
2169 updated to reflect the change. Special parameter 0 is unchanged. The
2170 first element of the FUNCNAME variable is set to the name of the funcâ€
2171 tion while the function is executing.
2172
2173 All other aspects of the shell execution environment are identical
2174 between a function and its caller with these exceptions: the DEBUG and
2175 RETURN traps (see the description of the trap builtin under SHELL
2176 BUILTIN COMMANDS below) are not inherited unless the function has been
2177 given the trace attribute (see the description of the declare builtin
2178 below) or the -o functrace shell option has been enabled with the set
2179 builtin (in which case all functions inherit the DEBUG and RETURN
2180 traps), and the ERR trap is not inherited unless the -o errtrace shell
2181 option has been enabled.
2182
2183 Variables local to the function may be declared with the local builtin
2184 command. Ordinarily, variables and their values are shared between the
2185 function and its caller.
2186
2187 The FUNCNEST variable, if set to a numeric value greater than 0,
2188 defines a maximum function nesting level. Function invocations that
2189 exceed the limit cause the entire command to abort.
2190
2191 If the builtin command return is executed in a function, the function
2192 completes and execution resumes with the next command after the funcâ€
2193 tion call. Any command associated with the RETURN trap is executed
2194 before execution resumes. When a function completes, the values of the
2195 positional parameters and the special parameter # are restored to the
2196 values they had prior to the function's execution.
2197
2198 Function names and definitions may be listed with the -f option to the
2199 declare or typeset builtin commands. The -F option to declare or typeâ€
2200 set will list the function names only (and optionally the source file
2201 and line number, if the extdebug shell option is enabled). Functions
2202 may be exported so that subshells automatically have them defined with
2203 the -f option to the export builtin. A function definition may be
2204 deleted using the -f option to the unset builtin. Note that shell
2205 functions and variables with the same name may result in multiple idenâ€
2206 tically-named entries in the environment passed to the shell's chilâ€
2207 dren. Care should be taken in cases where this may cause a problem.
2208
2209 Functions may be recursive. The FUNCNEST variable may be used to limit
2210 the depth of the function call stack and restrict the number of funcâ€
2211 tion invocations. By default, no limit is imposed on the number of
2212 recursive calls.
2213
2214ARITHMETIC EVALUATION
2215 The shell allows arithmetic expressions to be evaluated, under certain
2216 circumstances (see the let and declare builtin commands and Arithmetic
2217 Expansion). Evaluation is done in fixed-width integers with no check
2218 for overflow, though division by 0 is trapped and flagged as an error.
2219 The operators and their precedence, associativity, and values are the
2220 same as in the C language. The following list of operators is grouped
2221 into levels of equal-precedence operators. The levels are listed in
2222 order of decreasing precedence.
2223
2224 id++ id--
2225 variable post-increment and post-decrement
2226 ++id --id
2227 variable pre-increment and pre-decrement
2228 - + unary minus and plus
2229 ! ~ logical and bitwise negation
2230 ** exponentiation
2231 * / % multiplication, division, remainder
2232 + - addition, subtraction
2233 << >> left and right bitwise shifts
2234 <= >= < >
2235 comparison
2236 == != equality and inequality
2237 & bitwise AND
2238 ^ bitwise exclusive OR
2239 | bitwise OR
2240 && logical AND
2241 || logical OR
2242 expr?expr:expr
2243 conditional operator
2244 = *= /= %= += -= <<= >>= &= ^= |=
2245 assignment
2246 expr1 , expr2
2247 comma
2248
2249 Shell variables are allowed as operands; parameter expansion is perâ€
2250 formed before the expression is evaluated. Within an expression, shell
2251 variables may also be referenced by name without using the parameter
2252 expansion syntax. A shell variable that is null or unset evaluates to
2253 0 when referenced by name without using the parameter expansion syntax.
2254 The value of a variable is evaluated as an arithmetic expression when
2255 it is referenced, or when a variable which has been given the integer
2256 attribute using declare -i is assigned a value. A null value evaluates
2257 to 0. A shell variable need not have its integer attribute turned on
2258 to be used in an expression.
2259
2260 Constants with a leading 0 are interpreted as octal numbers. A leading
2261 0x or 0X denotes hexadecimal. Otherwise, numbers take the form
2262 [base#]n, where the optional base is a decimal number between 2 and 64
2263 representing the arithmetic base, and n is a number in that base. If
2264 base# is omitted, then base 10 is used. When specifying n, the digits
2265 greater< than 9 are represented by the lowercase letters, the uppercase
2266 letters, @, and _, in that order. If base is less than or equal to 36,
2267 lowercase and uppercase letters may be used interchangeably to repreâ€
2268 sent numbers between 10 and 35.
2269
2270 Operators are evaluated in order of precedence. Sub-expressions in
2271 parentheses are evaluated first and may override the precedence rules
2272 above.
2273
2274CONDITIONAL EXPRESSIONS
2275 Conditional expressions are used by the [[ compound command and the
2276 test and [ builtin commands to test file attributes and perform string
2277 and arithmetic comparisons. Expressions are formed from the following
2278 unary or binary primaries. If any file argument to one of the priâ€
2279 maries is of the form /dev/fd/n, then file descriptor n is checked. If
2280 the file argument to one of the primaries is one of /dev/stdin,
2281 /dev/stdout, or /dev/stderr, file descriptor 0, 1, or 2, respectively,
2282 is checked.
2283
2284 Unless otherwise specified, primaries that operate on files follow symâ€
2285 bolic links and operate on the target of the link, rather than the link
2286 itself.
2287
2288 When used with [[, the < and > operators sort lexicographically using
2289 the current locale. The test command sorts using ASCII ordering.
2290
2291 -a file
2292 True if file exists.
2293 -b file
2294 True if file exists and is a block special file.
2295 -c file
2296 True if file exists and is a character special file.
2297 -d file
2298 True if file exists and is a directory.
2299 -e file
2300 True if file exists.
2301 -f file
2302 True if file exists and is a regular file.
2303 -g file
2304 True if file exists and is set-group-id.
2305 -h file
2306 True if file exists and is a symbolic link.
2307 -k file
2308 True if file exists and its ``sticky'' bit is set.
2309 -p file
2310 True if file exists and is a named pipe (FIFO).
2311 -r file
2312 True if file exists and is readable.
2313 -s file
2314 True if file exists and has a size greater than zero.
2315 -t fd True if file descriptor fd is open and refers to a terminal.
2316 -u file
2317 True if file exists and its set-user-id bit is set.
2318 -w file
2319 True if file exists and is writable.
2320 -x file
2321 True if file exists and is executable.
2322 -G file
2323 True if file exists and is owned by the effective group id.
2324 -L file
2325 True if file exists and is a symbolic link.
2326 -N file
2327 True if file exists and has been modified since it was last
2328 read.
2329 -O file
2330 True if file exists and is owned by the effective user id.
2331 -S file
2332 True if file exists and is a socket.
2333 file1 -ef file2
2334 True if file1 and file2 refer to the same device and inode numâ€
2335 bers.
2336 file1 -nt file2
2337 True if file1 is newer (according to modification date) than
2338 file2, or if file1 exists and file2 does not.
2339 file1 -ot file2
2340 True if file1 is older than file2, or if file2 exists and file1
2341 does not.
2342 -o optname
2343 True if the shell option optname is enabled. See the list of
2344 options under the description of the -o option to the set
2345 builtin below.
2346 -v varname
2347 True if the shell variable varname is set (has been assigned a
2348 value).
2349 -R varname
2350 True if the shell variable varname is set and is a name referâ€
2351 ence.
2352 -z string
2353 True if the length of string is zero.
2354 string
2355 -n string
2356 True if the length of string is non-zero.
2357
2358 string1 == string2
2359 string1 = string2
2360 True if the strings are equal. = should be used with the test
2361 command for POSIX conformance. When used with the [[ command,
2362 this performs pattern matching as described above (Compound Comâ€
2363 mands).
2364
2365 string1 != string2
2366 True if the strings are not equal.
2367
2368 string1 < string2
2369 True if string1 sorts before string2 lexicographically.
2370
2371 string1 > string2
2372 True if string1 sorts after string2 lexicographically.
2373
2374 arg1 OP arg2
2375 OP is one of -eq, -ne, -lt, -le, -gt, or -ge. These arithmetic
2376 binary operators return true if arg1 is equal to, not equal to,
2377 less than, less than or equal to, greater than, or greater than
2378 or equal to arg2, respectively. Arg1 and arg2 may be positive
2379 or negative integers.
2380
2381SIMPLE COMMAND EXPANSION
2382 When a simple command is executed, the shell performs the following
2383 expansions, assignments, and redirections, from left to right.
2384
2385 1. The words that the parser has marked as variable assignments
2386 (those preceding the command name) and redirections are saved
2387 for later processing.
2388
2389 2. The words that are not variable assignments or redirections are
2390 expanded. If any words remain after expansion, the first word
2391 is taken to be the name of the command and the remaining words
2392 are the arguments.
2393
2394 3. Redirections are performed as described above under REDIRECTION.
2395
2396 4. The text after the = in each variable assignment undergoes tilde
2397 expansion, parameter expansion, command substitution, arithmetic
2398 expansion, and quote removal before being assigned to the variâ€
2399 able.
2400
2401 If no command name results, the variable assignments affect the current
2402 shell environment. Otherwise, the variables are added to the environâ€
2403 ment of the executed command and do not affect the current shell enviâ€
2404 ronment. If any of the assignments attempts to assign a value to a
2405 readonly variable, an error occurs, and the command exits with a non-
2406 zero status.
2407
2408 If no command name results, redirections are performed, but do not
2409 affect the current shell environment. A redirection error causes the
2410 command to exit with a non-zero status.
2411
2412 If there is a command name left after expansion, execution proceeds as
2413 described below. Otherwise, the command exits. If one of the expanâ€
2414 sions contained a command substitution, the exit status of the command
2415 is the exit status of the last command substitution performed. If
2416 there were no command substitutions, the command exits with a status of
2417 zero.
2418
2419COMMAND EXECUTION
2420 After a command has been split into words, if it results in a simple
2421 command and an optional list of arguments, the following actions are
2422 taken.
2423
2424 If the command name contains no slashes, the shell attempts to locate
2425 it. If there exists a shell function by that name, that function is
2426 invoked as described above in FUNCTIONS. If the name does not match a
2427 function, the shell searches for it in the list of shell builtins. If
2428 a match is found, that builtin is invoked.
2429
2430 If the name is neither a shell function nor a builtin, and contains no
2431 slashes, bash searches each element of the PATH for a directory conâ€
2432 taining an executable file by that name. Bash uses a hash table to
2433 remember the full pathnames of executable files (see hash under SHELL
2434 BUILTIN COMMANDS below). A full search of the directories in PATH is
2435 performed only if the command is not found in the hash table. If the
2436 search is unsuccessful, the shell searches for a defined shell function
2437 named command_not_found_handle. If that function exists, it is invoked
2438 with the original command and the original command's arguments as its
2439 arguments, and the function's exit status becomes the exit status of
2440 the shell. If that function is not defined, the shell prints an error
2441 message and returns an exit status of 127.
2442
2443 If the search is successful, or if the command name contains one or
2444 more slashes, the shell executes the named program in a separate execuâ€
2445 tion environment. Argument 0 is set to the name given, and the remainâ€
2446 ing arguments to the command are set to the arguments given, if any.
2447
2448 If this execution fails because the file is not in executable format,
2449 and the file is not a directory, it is assumed to be a shell script, a
2450 file containing shell commands. A subshell is spawned to execute it.
2451 This subshell reinitializes itself, so that the effect is as if a new
2452 shell had been invoked to handle the script, with the exception that
2453 the locations of commands remembered by the parent (see hash below
2454 under SHELL BUILTIN COMMANDS) are retained by the child.
2455
2456 If the program is a file beginning with #!, the remainder of the first
2457 line specifies an interpreter for the program. The shell executes the
2458 specified interpreter on operating systems that do not handle this exeâ€
2459 cutable format themselves. The arguments to the interpreter consist of
2460 a single optional argument following the interpreter name on the first
2461 line of the program, followed by the name of the program, followed by
2462 the command arguments, if any.
2463
2464COMMAND EXECUTION ENVIRONMENT
2465 The shell has an execution environment, which consists of the followâ€
2466 ing:
2467
2468 · open files inherited by the shell at invocation, as modified by
2469 redirections supplied to the exec builtin
2470
2471 · the current working directory as set by cd, pushd, or popd, or
2472 inherited by the shell at invocation
2473
2474 · the file creation mode mask as set by umask or inherited from
2475 the shell's parent
2476
2477 · current traps set by trap
2478
2479 · shell parameters that are set by variable assignment or with set
2480 or inherited from the shell's parent in the environment
2481
2482 · shell functions defined during execution or inherited from the
2483 shell's parent in the environment
2484
2485 · options enabled at invocation (either by default or with comâ€
2486 mand-line arguments) or by set
2487
2488 · options enabled by shopt
2489
2490 · shell aliases defined with alias
2491
2492 · various process IDs, including those of background jobs, the
2493 value of $$, and the value of PPID
2494
2495 When a simple command other than a builtin or shell function is to be
2496 executed, it is invoked in a separate execution environment that conâ€
2497 sists of the following. Unless otherwise noted, the values are inherâ€
2498 ited from the shell.
2499
2500 · the shell's open files, plus any modifications and additions
2501 specified by redirections to the command
2502
2503 · the current working directory
2504
2505 · the file creation mode mask
2506
2507 · shell variables and functions marked for export, along with
2508 variables exported for the command, passed in the environment
2509
2510 · traps caught by the shell are reset to the values inherited from
2511 the shell's parent, and traps ignored by the shell are ignored
2512
2513 A command invoked in this separate environment cannot affect the
2514 shell's execution environment.
2515
2516 Command substitution, commands grouped with parentheses, and asynchroâ€
2517 nous commands are invoked in a subshell environment that is a duplicate
2518 of the shell environment, except that traps caught by the shell are
2519 reset to the values that the shell inherited from its parent at invocaâ€
2520 tion. Builtin commands that are invoked as part of a pipeline are also
2521 executed in a subshell environment. Changes made to the subshell enviâ€
2522 ronment cannot affect the shell's execution environment.
2523
2524 Subshells spawned to execute command substitutions inherit the value of
2525 the -e option from the parent shell. When not in posix mode, bash
2526 clears the -e option in such subshells.
2527
2528 If a command is followed by a & and job control is not active, the
2529 default standard input for the command is the empty file /dev/null.
2530 Otherwise, the invoked command inherits the file descriptors of the
2531 calling shell as modified by redirections.
2532
2533ENVIRONMENT
2534 When a program is invoked it is given an array of strings called the
2535 environment. This is a list of name-value pairs, of the form
2536 name=value.
2537
2538 The shell provides several ways to manipulate the environment. On
2539 invocation, the shell scans its own environment and creates a parameter
2540 for each name found, automatically marking it for export to child proâ€
2541 cesses. Executed commands inherit the environment. The export and
2542 declare -x commands allow parameters and functions to be added to and
2543 deleted from the environment. If the value of a parameter in the enviâ€
2544 ronment is modified, the new value becomes part of the environment,
2545 replacing the old. The environment inherited by any executed command
2546 consists of the shell's initial environment, whose values may be modiâ€
2547 fied in the shell, less any pairs removed by the unset command, plus
2548 any additions via the export and declare -x commands.
2549
2550 The environment for any simple command or function may be augmented
2551 temporarily by prefixing it with parameter assignments, as described
2552 above in PARAMETERS. These assignment statements affect only the enviâ€
2553 ronment seen by that command.
2554
2555 If the -k option is set (see the set builtin command below), then all
2556 parameter assignments are placed in the environment for a command, not
2557 just those that precede the command name.
2558
2559 When bash invokes an external command, the variable _ is set to the
2560 full filename of the command and passed to that command in its environâ€
2561 ment.
2562
2563EXIT STATUS
2564 The exit status of an executed command is the value returned by the
2565 waitpid system call or equivalent function. Exit statuses fall between
2566 0 and 255, though, as explained below, the shell may use values above
2567 125 specially. Exit statuses from shell builtins and compound commands
2568 are also limited to this range. Under certain circumstances, the shell
2569 will use special values to indicate specific failure modes.
2570
2571 For the shell's purposes, a command which exits with a zero exit status
2572 has succeeded. An exit status of zero indicates success. A non-zero
2573 exit status indicates failure. When a command terminates on a fatal
2574 signal N, bash uses the value of 128+N as the exit status.
2575
2576 If a command is not found, the child process created to execute it
2577 returns a status of 127. If a command is found but is not executable,
2578 the return status is 126.
2579
2580 If a command fails because of an error during expansion or redirection,
2581 the exit status is greater than zero.
2582
2583 Shell builtin commands return a status of 0 (true) if successful, and
2584 non-zero (false) if an error occurs while they execute. All builtins
2585 return an exit status of 2 to indicate incorrect usage.
2586
2587 Bash itself returns the exit status of the last command executed,
2588 unless a syntax error occurs, in which case it exits with a non-zero
2589 value. See also the exit builtin command below.
2590
2591SIGNALS
2592 When bash is interactive, in the absence of any traps, it ignores
2593 SIGTERM (so that kill 0 does not kill an interactive shell), and SIGINT
2594 is caught and handled (so that the wait builtin is interruptible). In
2595 all cases, bash ignores SIGQUIT. If job control is in effect, bash
2596 ignores SIGTTIN, SIGTTOU, and SIGTSTP.
2597
2598 Non-builtin commands run by bash have signal handlers set to the values
2599 inherited by the shell from its parent. When job control is not in
2600 effect, asynchronous commands ignore SIGINT and SIGQUIT in addition to
2601 these inherited handlers. Commands run as a result of command substiâ€
2602 tution ignore the keyboard-generated job control signals SIGTTIN, SIGTâ€
2603 TOU, and SIGTSTP.
2604
2605 The shell exits by default upon receipt of a SIGHUP. Before exiting,
2606 an interactive shell resends the SIGHUP to all jobs, running or
2607 stopped. Stopped jobs are sent SIGCONT to ensure that they receive the
2608 SIGHUP. To prevent the shell from sending the signal to a particular
2609 job, it should be removed from the jobs table with the disown builtin
2610 (see SHELL BUILTIN COMMANDS below) or marked to not receive SIGHUP
2611 using disown -h.
2612
2613 If the huponexit shell option has been set with shopt, bash sends a
2614 SIGHUP to all jobs when an interactive login shell exits.
2615
2616 If bash is waiting for a command to complete and receives a signal for
2617 which a trap has been set, the trap will not be executed until the comâ€
2618 mand completes. When bash is waiting for an asynchronous command via
2619 the wait builtin, the reception of a signal for which a trap has been
2620 set will cause the wait builtin to return immediately with an exit staâ€
2621 tus greater than 128, immediately after which the trap is executed.
2622
2623JOB CONTROL
2624 Job control refers to the ability to selectively stop (suspend) the
2625 execution of processes and continue (resume) their execution at a later
2626 point. A user typically employs this facility via an interactive
2627 interface supplied jointly by the operating system kernel's terminal
2628 driver and bash.
2629
2630 The shell associates a job with each pipeline. It keeps a table of
2631 currently executing jobs, which may be listed with the jobs command.
2632 When bash starts a job asynchronously (in the background), it prints a
2633 line that looks like:
2634
2635 [1] 25647
2636
2637 indicating that this job is job number 1 and that the process ID of the
2638 last process in the pipeline associated with this job is 25647. All of
2639 the processes in a single pipeline are members of the same job. Bash
2640 uses the job abstraction as the basis for job control.
2641
2642 To facilitate the implementation of the user interface to job control,
2643 the operating system maintains the notion of a current terminal process
2644 group ID. Members of this process group (processes whose process group
2645 ID is equal to the current terminal process group ID) receive keyboard-
2646 generated signals such as SIGINT. These processes are said to be in
2647 the foreground. Background processes are those whose process group ID
2648 differs from the terminal's; such processes are immune to keyboard-genâ€
2649 erated signals. Only foreground processes are allowed to read from or,
2650 if the user so specifies with stty tostop, write to the terminal.
2651 Background processes which attempt to read from (write to when stty
2652 tostop is in effect) the terminal are sent a SIGTTIN (SIGTTOU) signal
2653 by the kernel's terminal driver, which, unless caught, suspends the
2654 process.
2655
2656 If the operating system on which bash is running supports job control,
2657 bash contains facilities to use it. Typing the suspend character (typâ€
2658 ically ^Z, Control-Z) while a process is running causes that process to
2659 be stopped and returns control to bash. Typing the delayed suspend
2660 character (typically ^Y, Control-Y) causes the process to be stopped
2661 when it attempts to read input from the terminal, and control to be
2662 returned to bash. The user may then manipulate the state of this job,
2663 using the bg command to continue it in the background, the fg command
2664 to continue it in the foreground, or the kill command to kill it. A ^Z
2665 takes effect immediately, and has the additional side effect of causing
2666 pending output and typeahead to be discarded.
2667
2668 There are a number of ways to refer to a job in the shell. The characâ€
2669 ter % introduces a job specification (jobspec). Job number n may be
2670 referred to as %n. A job may also be referred to using a prefix of the
2671 name used to start it, or using a substring that appears in its command
2672 line. For example, %ce refers to a stopped ce job. If a prefix
2673 matches more than one job, bash reports an error. Using %?ce, on the
2674 other hand, refers to any job containing the string ce in its command
2675 line. If the substring matches more than one job, bash reports an
2676 error. The symbols %% and %+ refer to the shell's notion of the curâ€
2677 rent job, which is the last job stopped while it was in the foreground
2678 or started in the background. The previous job may be referenced using
2679 %-. If there is only a single job, %+ and %- can both be used to refer
2680 to that job. In output pertaining to jobs (e.g., the output of the
2681 jobs command), the current job is always flagged with a +, and the preâ€
2682 vious job with a -. A single % (with no accompanying job specificaâ€
2683 tion) also refers to the current job.
2684
2685 Simply naming a job can be used to bring it into the foreground: %1 is
2686 a synonym for ``fg %1'', bringing job 1 from the background into the
2687 foreground. Similarly, ``%1 &'' resumes job 1 in the background,
2688 equivalent to ``bg %1''.
2689
2690 The shell learns immediately whenever a job changes state. Normally,
2691 bash waits until it is about to print a prompt before reporting changes
2692 in a job's status so as to not interrupt any other output. If the -b
2693 option to the set builtin command is enabled, bash reports such changes
2694 immediately. Any trap on SIGCHLD is executed for each child that
2695 exits.
2696
2697 If an attempt to exit bash is made while jobs are stopped (or, if the
2698 checkjobs shell option has been enabled using the shopt builtin, runâ€
2699 ning), the shell prints a warning message, and, if the checkjobs option
2700 is enabled, lists the jobs and their statuses. The jobs command may
2701 then be used to inspect their status. If a second attempt to exit is
2702 made without an intervening command, the shell does not print another
2703 warning, and any stopped jobs are terminated.
2704
2705PROMPTING
2706 When executing interactively, bash displays the primary prompt PS1 when
2707 it is ready to read a command, and the secondary prompt PS2 when it
2708 needs more input to complete a command. Bash allows these prompt
2709 strings to be customized by inserting a number of backslash-escaped
2710 special characters that are decoded as follows:
2711 \a an ASCII bell character (07)
2712 \d the date in "Weekday Month Date" format (e.g., "Tue May
2713 26")
2714 \D{format}
2715 the format is passed to strftime(3) and the result is
2716 inserted into the prompt string; an empty format results
2717 in a locale-specific time representation. The braces are
2718 required
2719 \e an ASCII escape character (033)
2720 \h the hostname up to the first `.'
2721 \H the hostname
2722 \j the number of jobs currently managed by the shell
2723 \l the basename of the shell's terminal device name
2724 \n newline
2725 \r carriage return
2726 \s the name of the shell, the basename of $0 (the portion
2727 following the final slash)
2728 \t the current time in 24-hour HH:MM:SS format
2729 \T the current time in 12-hour HH:MM:SS format
2730 \@ the current time in 12-hour am/pm format
2731 \A the current time in 24-hour HH:MM format
2732 \u the username of the current user
2733 \v the version of bash (e.g., 2.00)
2734 \V the release of bash, version + patch level (e.g., 2.00.0)
2735 \w the current working directory, with $HOME abbreviated
2736 with a tilde (uses the value of the PROMPT_DIRTRIM variâ€
2737 able)
2738 \W the basename of the current working directory, with $HOME
2739 abbreviated with a tilde
2740 \! the history number of this command
2741 \# the command number of this command
2742 \$ if the effective UID is 0, a #, otherwise a $
2743 \nnn the character corresponding to the octal number nnn
2744 \\ a backslash
2745 \[ begin a sequence of non-printing characters, which could
2746 be used to embed a terminal control sequence into the
2747 prompt
2748 \] end a sequence of non-printing characters
2749
2750 The command number and the history number are usually different: the
2751 history number of a command is its position in the history list, which
2752 may include commands restored from the history file (see HISTORY
2753 below), while the command number is the position in the sequence of
2754 commands executed during the current shell session. After the string
2755 is decoded, it is expanded via parameter expansion, command substituâ€
2756 tion, arithmetic expansion, and quote removal, subject to the value of
2757 the promptvars shell option (see the description of the shopt command
2758 under SHELL BUILTIN COMMANDS below).
2759
2760READLINE
2761 This is the library that handles reading input when using an interacâ€
2762 tive shell, unless the --noediting option is given at shell invocation.
2763 Line editing is also used when using the -e option to the read builtin.
2764 By default, the line editing commands are similar to those of Emacs. A
2765 vi-style line editing interface is also available. Line editing can be
2766 enabled at any time using the -o emacs or -o vi options to the set
2767 builtin (see SHELL BUILTIN COMMANDS below). To turn off line editing
2768 after the shell is running, use the +o emacs or +o vi options to the
2769 set builtin.
2770
2771 Readline Notation
2772 In this section, the Emacs-style notation is used to denote keystrokes.
2773 Control keys are denoted by C-key, e.g., C-n means Control-N. Simiâ€
2774 larly, meta keys are denoted by M-key, so M-x means Meta-X. (On keyâ€
2775 boards without a meta key, M-x means ESC x, i.e., press the Escape key
2776 then the x key. This makes ESC the meta prefix. The combination M-C-x
2777 means ESC-Control-x, or press the Escape key then hold the Control key
2778 while pressing the x key.)
2779
2780 Readline commands may be given numeric arguments, which normally act as
2781 a repeat count. Sometimes, however, it is the sign of the argument
2782 that is significant. Passing a negative argument to a command that
2783 acts in the forward direction (e.g., kill-line) causes that command to
2784 act in a backward direction. Commands whose behavior with arguments
2785 deviates from this are noted below.
2786
2787 When a command is described as killing text, the text deleted is saved
2788 for possible future retrieval (yanking). The killed text is saved in a
2789 kill ring. Consecutive kills cause the text to be accumulated into one
2790 unit, which can be yanked all at once. Commands which do not kill text
2791 separate the chunks of text on the kill ring.
2792
2793 Readline Initialization
2794 Readline is customized by putting commands in an initialization file
2795 (the inputrc file). The name of this file is taken from the value of
2796 the INPUTRC variable. If that variable is unset, the default is
2797 ~/.inputrc. When a program which uses the readline library starts up,
2798 the initialization file is read, and the key bindings and variables are
2799 set. There are only a few basic constructs allowed in the readline
2800 initialization file. Blank lines are ignored. Lines beginning with a
2801 # are comments. Lines beginning with a $ indicate conditional conâ€
2802 structs. Other lines denote key bindings and variable settings.
2803
2804 The default key-bindings may be changed with an inputrc file. Other
2805 programs that use this library may add their own commands and bindings.
2806
2807 For example, placing
2808
2809 M-Control-u: universal-argument
2810 or
2811 C-Meta-u: universal-argument
2812 into the inputrc would make M-C-u execute the readline command univerâ€
2813 sal-argument.
2814
2815 The following symbolic character names are recognized: RUBOUT, DEL,
2816 ESC, LFD, NEWLINE, RET, RETURN, SPC, SPACE, and TAB.
2817
2818 In addition to command names, readline allows keys to be bound to a
2819 string that is inserted when the key is pressed (a macro).
2820
2821 Readline Key Bindings
2822 The syntax for controlling key bindings in the inputrc file is simple.
2823 All that is required is the name of the command or the text of a macro
2824 and a key sequence to which it should be bound. The name may be speciâ€
2825 fied in one of two ways: as a symbolic key name, possibly with Meta- or
2826 Control- prefixes, or as a key sequence.
2827
2828 When using the form keyname:function-name or macro, keyname is the name
2829 of a key spelled out in English. For example:
2830
2831 Control-u: universal-argument
2832 Meta-Rubout: backward-kill-word
2833 Control-o: "> output"
2834
2835 In the above example, C-u is bound to the function universal-argument,
2836 M-DEL is bound to the function backward-kill-word, and C-o is bound to
2837 run the macro expressed on the right hand side (that is, to insert the
2838 text ``> output'' into the line).
2839
2840 In the second form, "keyseq":function-name or macro, keyseq differs
2841 from keyname above in that strings denoting an entire key sequence may
2842 be specified by placing the sequence within double quotes. Some GNU
2843 Emacs style key escapes can be used, as in the following example, but
2844 the symbolic character names are not recognized.
2845
2846 "\C-u": universal-argument
2847 "\C-x\C-r": re-read-init-file
2848 "\e[11~": "Function Key 1"
2849
2850 In this example, C-u is again bound to the function universal-argument.
2851 C-x C-r is bound to the function re-read-init-file, and ESC [ 1 1 ~ is
2852 bound to insert the text ``Function Key 1''.
2853
2854 The full set of GNU Emacs style escape sequences is
2855 \C- control prefix
2856 \M- meta prefix
2857 \e an escape character
2858 \\ backslash
2859 \" literal "
2860 \' literal '
2861
2862 In addition to the GNU Emacs style escape sequences, a second set of
2863 backslash escapes is available:
2864 \a alert (bell)
2865 \b backspace
2866 \d delete
2867 \f form feed
2868 \n newline
2869 \r carriage return
2870 \t horizontal tab
2871 \v vertical tab
2872 \nnn the eight-bit character whose value is the octal value
2873 nnn (one to three digits)
2874 \xHH the eight-bit character whose value is the hexadecimal
2875 value HH (one or two hex digits)
2876
2877 When entering the text of a macro, single or double quotes must be used
2878 to indicate a macro definition. Unquoted text is assumed to be a funcâ€
2879 tion name. In the macro body, the backslash escapes described above
2880 are expanded. Backslash will quote any other character in the macro
2881 text, including " and '.
2882
2883 Bash allows the current readline key bindings to be displayed or modiâ€
2884 fied with the bind builtin command. The editing mode may be switched
2885 during interactive use by using the -o option to the set builtin comâ€
2886 mand (see SHELL BUILTIN COMMANDS below).
2887
2888 Readline Variables
2889 Readline has variables that can be used to further customize its behavâ€
2890 ior. A variable may be set in the inputrc file with a statement of the
2891 form
2892
2893 set variable-name value
2894
2895 Except where noted, readline variables can take the values On or Off
2896 (without regard to case). Unrecognized variable names are ignored.
2897 When a variable value is read, empty or null values, "on" (case-insenâ€
2898 sitive), and "1" are equivalent to On. All other values are equivalent
2899 to Off. The variables and their default values are:
2900
2901 bell-style (audible)
2902 Controls what happens when readline wants to ring the terminal
2903 bell. If set to none, readline never rings the bell. If set to
2904 visible, readline uses a visible bell if one is available. If
2905 set to audible, readline attempts to ring the terminal's bell.
2906 bind-tty-special-chars (On)
2907 If set to On, readline attempts to bind the control characters
2908 treated specially by the kernel's terminal driver to their readâ€
2909 line equivalents.
2910 colored-stats (Off)
2911 If set to On, readline displays possible completions using difâ€
2912 ferent colors to indicate their file type. The color definiâ€
2913 tions are taken from the value of the LS_COLORS environment
2914 variable.
2915 comment-begin (``#'')
2916 The string that is inserted when the readline insert-comment
2917 command is executed. This command is bound to M-# in emacs mode
2918 and to # in vi command mode.
2919 completion-ignore-case (Off)
2920 If set to On, readline performs filename matching and completion
2921 in a case-insensitive fashion.
2922 completion-prefix-display-length (0)
2923 The length in characters of the common prefix of a list of posâ€
2924 sible completions that is displayed without modification. When
2925 set to a value greater than zero, common prefixes longer than
2926 this value are replaced with an ellipsis when displaying possiâ€
2927 ble completions.
2928 completion-query-items (100)
2929 This determines when the user is queried about viewing the numâ€
2930 ber of possible completions generated by the possible-compleâ€
2931 tions command. It may be set to any integer value greater than
2932 or equal to zero. If the number of possible completions is
2933 greater than or equal to the value of this variable, the user is
2934 asked whether or not he wishes to view them; otherwise they are
2935 simply listed on the terminal.
2936 convert-meta (On)
2937 If set to On, readline will convert characters with the eighth
2938 bit set to an ASCII key sequence by stripping the eighth bit and
2939 prefixing an escape character (in effect, using escape as the
2940 meta prefix).
2941 disable-completion (Off)
2942 If set to On, readline will inhibit word completion. Completion
2943 characters will be inserted into the line as if they had been
2944 mapped to self-insert.
2945 editing-mode (emacs)
2946 Controls whether readline begins with a set of key bindings simâ€
2947 ilar to Emacs or vi. editing-mode can be set to either emacs or
2948 vi.
2949 echo-control-characters (On)
2950 When set to On, on operating systems that indicate they support
2951 it, readline echoes a character corresponding to a signal generâ€
2952 ated from the keyboard.
2953 enable-keypad (Off)
2954 When set to On, readline will try to enable the application keyâ€
2955 pad when it is called. Some systems need this to enable the
2956 arrow keys.
2957 enable-meta-key (On)
2958 When set to On, readline will try to enable any meta modifier
2959 key the terminal claims to support when it is called. On many
2960 terminals, the meta key is used to send eight-bit characters.
2961 expand-tilde (Off)
2962 If set to On, tilde expansion is performed when readline
2963 attempts word completion.
2964 history-preserve-point (Off)
2965 If set to On, the history code attempts to place point at the
2966 same location on each history line retrieved with previous-hisâ€
2967 tory or next-history.
2968 history-size (0)
2969 Set the maximum number of history entries saved in the history
2970 list. If set to zero, any existing history entries are deleted
2971 and no new entries are saved. If set to a value less than zero,
2972 the number of history entries is not limited. By default, the
2973 number of history entries is not limited.
2974 horizontal-scroll-mode (Off)
2975 When set to On, makes readline use a single line for display,
2976 scrolling the input horizontally on a single screen line when it
2977 becomes longer than the screen width rather than wrapping to a
2978 new line.
2979 input-meta (Off)
2980 If set to On, readline will enable eight-bit input (that is, it
2981 will not strip the high bit from the characters it reads),
2982 regardless of what the terminal claims it can support. The name
2983 meta-flag is a synonym for this variable.
2984 isearch-terminators (``C-[C-J'')
2985 The string of characters that should terminate an incremental
2986 search without subsequently executing the character as a comâ€
2987 mand. If this variable has not been given a value, the characâ€
2988 ters ESC and C-J will terminate an incremental search.
2989 keymap (emacs)
2990 Set the current readline keymap. The set of valid keymap names
2991 is emacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-comâ€
2992 mand, and vi-insert. vi is equivalent to vi-command; emacs is
2993 equivalent to emacs-standard. The default value is emacs; the
2994 value of editing-mode also affects the default keymap.
2995 keyseq-timeout (500)
2996 Specifies the duration readline will wait for a character when
2997 reading an ambiguous key sequence (one that can form a complete
2998 key sequence using the input read so far, or can take additional
2999 input to complete a longer key sequence). If no input is
3000 received within the timeout, readline will use the shorter but
3001 complete key sequence. The value is specified in milliseconds,
3002 so a value of 1000 means that readline will wait one second for
3003 additional input. If this variable is set to a value less than
3004 or equal to zero, or to a non-numeric value, readline will wait
3005 until another key is pressed to decide which key sequence to
3006 complete.
3007 mark-directories (On)
3008 If set to On, completed directory names have a slash appended.
3009 mark-modified-lines (Off)
3010 If set to On, history lines that have been modified are disâ€
3011 played with a preceding asterisk (*).
3012 mark-symlinked-directories (Off)
3013 If set to On, completed names which are symbolic links to direcâ€
3014 tories have a slash appended (subject to the value of
3015 mark-directories).
3016 match-hidden-files (On)
3017 This variable, when set to On, causes readline to match files
3018 whose names begin with a `.' (hidden files) when performing
3019 filename completion. If set to Off, the leading `.' must be
3020 supplied by the user in the filename to be completed.
3021 menu-complete-display-prefix (Off)
3022 If set to On, menu completion displays the common prefix of the
3023 list of possible completions (which may be empty) before cycling
3024 through the list.
3025 output-meta (Off)
3026 If set to On, readline will display characters with the eighth
3027 bit set directly rather than as a meta-prefixed escape sequence.
3028 page-completions (On)
3029 If set to On, readline uses an internal more-like pager to disâ€
3030 play a screenful of possible completions at a time.
3031 print-completions-horizontally (Off)
3032 If set to On, readline will display completions with matches
3033 sorted horizontally in alphabetical order, rather than down the
3034 screen.
3035 revert-all-at-newline (Off)
3036 If set to On, readline will undo all changes to history lines
3037 before returning when accept-line is executed. By default, hisâ€
3038 tory lines may be modified and retain individual undo lists
3039 across calls to readline.
3040 show-all-if-ambiguous (Off)
3041 This alters the default behavior of the completion functions.
3042 If set to On, words which have more than one possible completion
3043 cause the matches to be listed immediately instead of ringing
3044 the bell.
3045 show-all-if-unmodified (Off)
3046 This alters the default behavior of the completion functions in
3047 a fashion similar to show-all-if-ambiguous. If set to On, words
3048 which have more than one possible completion without any possiâ€
3049 ble partial completion (the possible completions don't share a
3050 common prefix) cause the matches to be listed immediately
3051 instead of ringing the bell.
3052 show-mode-in-prompt (Off)
3053 If set to On, add a character to the beginning of the prompt
3054 indicating the editing mode: emacs (@), vi command (:) or vi
3055 insertion (+).
3056 skip-completed-text (Off)
3057 If set to On, this alters the default completion behavior when
3058 inserting a single match into the line. It's only active when
3059 performing completion in the middle of a word. If enabled,
3060 readline does not insert characters from the completion that
3061 match characters after point in the word being completed, so
3062 portions of the word following the cursor are not duplicated.
3063 visible-stats (Off)
3064 If set to On, a character denoting a file's type as reported by
3065 stat(2) is appended to the filename when listing possible comâ€
3066 pletions.
3067
3068 Readline Conditional Constructs
3069 Readline implements a facility similar in spirit to the conditional
3070 compilation features of the C preprocessor which allows key bindings
3071 and variable settings to be performed as the result of tests. There
3072 are four parser directives used.
3073
3074 $if The $if construct allows bindings to be made based on the editâ€
3075 ing mode, the terminal being used, or the application using
3076 readline. The text of the test extends to the end of the line;
3077 no characters are required to isolate it.
3078
3079 mode The mode= form of the $if directive is used to test
3080 whether readline is in emacs or vi mode. This may be
3081 used in conjunction with the set keymap command, for
3082 instance, to set bindings in the emacs-standard and
3083 emacs-ctlx keymaps only if readline is starting out in
3084 emacs mode.
3085
3086 term The term= form may be used to include terminal-specific
3087 key bindings, perhaps to bind the key sequences output by
3088 the terminal's function keys. The word on the right side
3089 of the = is tested against the both full name of the terâ€
3090 minal and the portion of the terminal name before the
3091 first -. This allows sun to match both sun and sun-cmd,
3092 for instance.
3093
3094 application
3095 The application construct is used to include application-
3096 specific settings. Each program using the readline
3097 library sets the application name, and an initialization
3098 file can test for a particular value. This could be used
3099 to bind key sequences to functions useful for a specific
3100 program. For instance, the following command adds a key
3101 sequence that quotes the current or previous word in
3102 bash:
3103
3104 $if Bash
3105 # Quote the current or previous word
3106 "\C-xq": "\eb\"\ef\""
3107 $endif
3108
3109 $endif This command, as seen in the previous example, terminates an $if
3110 command.
3111
3112 $else Commands in this branch of the $if directive are executed if the
3113 test fails.
3114
3115 $include
3116 This directive takes a single filename as an argument and reads
3117 commands and bindings from that file. For example, the followâ€
3118 ing directive would read /etc/inputrc:
3119
3120 $include /etc/inputrc
3121
3122 Searching
3123 Readline provides commands for searching through the command history
3124 (see HISTORY below) for lines containing a specified string. There are
3125 two search modes: incremental and non-incremental.
3126
3127 Incremental searches begin before the user has finished typing the
3128 search string. As each character of the search string is typed, readâ€
3129 line displays the next entry from the history matching the string typed
3130 so far. An incremental search requires only as many characters as
3131 needed to find the desired history entry. The characters present in
3132 the value of the isearch-terminators variable are used to terminate an
3133 incremental search. If that variable has not been assigned a value the
3134 Escape and Control-J characters will terminate an incremental search.
3135 Control-G will abort an incremental search and restore the original
3136 line. When the search is terminated, the history entry containing the
3137 search string becomes the current line.
3138
3139 To find other matching entries in the history list, type Control-S or
3140 Control-R as appropriate. This will search backward or forward in the
3141 history for the next entry matching the search string typed so far.
3142 Any other key sequence bound to a readline command will terminate the
3143 search and execute that command. For instance, a newline will termiâ€
3144 nate the search and accept the line, thereby executing the command from
3145 the history list.
3146
3147 Readline remembers the last incremental search string. If two Control-
3148 Rs are typed without any intervening characters defining a new search
3149 string, any remembered search string is used.
3150
3151 Non-incremental searches read the entire search string before starting
3152 to search for matching history lines. The search string may be typed
3153 by the user or be part of the contents of the current line.
3154
3155 Readline Command Names
3156 The following is a list of the names of the commands and the default
3157 key sequences to which they are bound. Command names without an accomâ€
3158 panying key sequence are unbound by default. In the following descripâ€
3159 tions, point refers to the current cursor position, and mark refers to
3160 a cursor position saved by the set-mark command. The text between the
3161 point and mark is referred to as the region.
3162
3163 Commands for Moving
3164 beginning-of-line (C-a)
3165 Move to the start of the current line.
3166 end-of-line (C-e)
3167 Move to the end of the line.
3168 forward-char (C-f)
3169 Move forward a character.
3170 backward-char (C-b)
3171 Move back a character.
3172 forward-word (M-f)
3173 Move forward to the end of the next word. Words are composed of
3174 alphanumeric characters (letters and digits).
3175 backward-word (M-b)
3176 Move back to the start of the current or previous word. Words
3177 are composed of alphanumeric characters (letters and digits).
3178 shell-forward-word
3179 Move forward to the end of the next word. Words are delimited
3180 by non-quoted shell metacharacters.
3181 shell-backward-word
3182 Move back to the start of the current or previous word. Words
3183 are delimited by non-quoted shell metacharacters.
3184 clear-screen (C-l)
3185 Clear the screen leaving the current line at the top of the
3186 screen. With an argument, refresh the current line without
3187 clearing the screen.
3188 redraw-current-line
3189 Refresh the current line.
3190
3191 Commands for Manipulating the History
3192 accept-line (Newline, Return)
3193 Accept the line regardless of where the cursor is. If this line
3194 is non-empty, add it to the history list according to the state
3195 of the HISTCONTROL variable. If the line is a modified history
3196 line, then restore the history line to its original state.
3197 previous-history (C-p)
3198 Fetch the previous command from the history list, moving back in
3199 the list.
3200 next-history (C-n)
3201 Fetch the next command from the history list, moving forward in
3202 the list.
3203 beginning-of-history (M-<)
3204 Move to the first line in the history.
3205 end-of-history (M->)
3206 Move to the end of the input history, i.e., the line currently
3207 being entered.
3208 reverse-search-history (C-r)
3209 Search backward starting at the current line and moving `up'
3210 through the history as necessary. This is an incremental
3211 search.
3212 forward-search-history (C-s)
3213 Search forward starting at the current line and moving `down'
3214 through the history as necessary. This is an incremental
3215 search.
3216 non-incremental-reverse-search-history (M-p)
3217 Search backward through the history starting at the current line
3218 using a non-incremental search for a string supplied by the
3219 user.
3220 non-incremental-forward-search-history (M-n)
3221 Search forward through the history using a non-incremental
3222 search for a string supplied by the user.
3223 history-search-forward
3224 Search forward through the history for the string of characters
3225 between the start of the current line and the point. This is a
3226 non-incremental search.
3227 history-search-backward
3228 Search backward through the history for the string of characters
3229 between the start of the current line and the point. This is a
3230 non-incremental search.
3231 yank-nth-arg (M-C-y)
3232 Insert the first argument to the previous command (usually the
3233 second word on the previous line) at point. With an argument n,
3234 insert the nth word from the previous command (the words in the
3235 previous command begin with word 0). A negative argument
3236 inserts the nth word from the end of the previous command. Once
3237 the argument n is computed, the argument is extracted as if the
3238 "!n" history expansion had been specified.
3239 yank-last-arg (M-., M-_)
3240 Insert the last argument to the previous command (the last word
3241 of the previous history entry). With a numeric argument, behave
3242 exactly like yank-nth-arg. Successive calls to yank-last-arg
3243 move back through the history list, inserting the last word (or
3244 the word specified by the argument to the first call) of each
3245 line in turn. Any numeric argument supplied to these successive
3246 calls determines the direction to move through the history. A
3247 negative argument switches the direction through the history
3248 (back or forward). The history expansion facilities are used to
3249 extract the last word, as if the "!$" history expansion had been
3250 specified.
3251 shell-expand-line (M-C-e)
3252 Expand the line as the shell does. This performs alias and hisâ€
3253 tory expansion as well as all of the shell word expansions. See
3254 HISTORY EXPANSION below for a description of history expansion.
3255 history-expand-line (M-^)
3256 Perform history expansion on the current line. See HISTORY
3257 EXPANSION below for a description of history expansion.
3258 magic-space
3259 Perform history expansion on the current line and insert a
3260 space. See HISTORY EXPANSION below for a description of history
3261 expansion.
3262 alias-expand-line
3263 Perform alias expansion on the current line. See ALIASES above
3264 for a description of alias expansion.
3265 history-and-alias-expand-line
3266 Perform history and alias expansion on the current line.
3267 insert-last-argument (M-., M-_)
3268 A synonym for yank-last-arg.
3269 operate-and-get-next (C-o)
3270 Accept the current line for execution and fetch the next line
3271 relative to the current line from the history for editing. Any
3272 argument is ignored.
3273 edit-and-execute-command (C-xC-e)
3274 Invoke an editor on the current command line, and execute the
3275 result as shell commands. Bash attempts to invoke $VISUAL,
3276 $EDITOR, and emacs as the editor, in that order.
3277
3278 Commands for Changing Text
3279 end-of-file (usually C-d)
3280 The character indicating end-of-file as set, for example, by
3281 ``stty''. If this character is read when there are no characâ€
3282 ters on the line, and point is at the beginning of the line,
3283 Readline interprets it as the end of input and returns EOF.
3284 delete-char (C-d)
3285 Delete the character at point. If this function is bound to the
3286 same character as the tty EOF character, as C-d commonly is, see
3287 above for the effects.
3288 backward-delete-char (Rubout)
3289 Delete the character behind the cursor. When given a numeric
3290 argument, save the deleted text on the kill ring.
3291 forward-backward-delete-char
3292 Delete the character under the cursor, unless the cursor is at
3293 the end of the line, in which case the character behind the curâ€
3294 sor is deleted.
3295 quoted-insert (C-q, C-v)
3296 Add the next character typed to the line verbatim. This is how
3297 to insert characters like C-q, for example.
3298 tab-insert (C-v TAB)
3299 Insert a tab character.
3300 self-insert (a, b, A, 1, !, ...)
3301 Insert the character typed.
3302 transpose-chars (C-t)
3303 Drag the character before point forward over the character at
3304 point, moving point forward as well. If point is at the end of
3305 the line, then this transposes the two characters before point.
3306 Negative arguments have no effect.
3307 transpose-words (M-t)
3308 Drag the word before point past the word after point, moving
3309 point over that word as well. If point is at the end of the
3310 line, this transposes the last two words on the line.
3311 upcase-word (M-u)
3312 Uppercase the current (or following) word. With a negative
3313 argument, uppercase the previous word, but do not move point.
3314 downcase-word (M-l)
3315 Lowercase the current (or following) word. With a negative
3316 argument, lowercase the previous word, but do not move point.
3317 capitalize-word (M-c)
3318 Capitalize the current (or following) word. With a negative
3319 argument, capitalize the previous word, but do not move point.
3320 overwrite-mode
3321 Toggle overwrite mode. With an explicit positive numeric arguâ€
3322 ment, switches to overwrite mode. With an explicit non-positive
3323 numeric argument, switches to insert mode. This command affects
3324 only emacs mode; vi mode does overwrite differently. Each call
3325 to readline() starts in insert mode. In overwrite mode, characâ€
3326 ters bound to self-insert replace the text at point rather than
3327 pushing the text to the right. Characters bound to backâ€
3328 ward-delete-char replace the character before point with a
3329 space. By default, this command is unbound.
3330
3331 Killing and Yanking
3332 kill-line (C-k)
3333 Kill the text from point to the end of the line.
3334 backward-kill-line (C-x Rubout)
3335 Kill backward to the beginning of the line.
3336 unix-line-discard (C-u)
3337 Kill backward from point to the beginning of the line. The
3338 killed text is saved on the kill-ring.
3339 kill-whole-line
3340 Kill all characters on the current line, no matter where point
3341 is.
3342 kill-word (M-d)
3343 Kill from point to the end of the current word, or if between
3344 words, to the end of the next word. Word boundaries are the
3345 same as those used by forward-word.
3346 backward-kill-word (M-Rubout)
3347 Kill the word behind point. Word boundaries are the same as
3348 those used by backward-word.
3349 shell-kill-word (M-d)
3350 Kill from point to the end of the current word, or if between
3351 words, to the end of the next word. Word boundaries are the
3352 same as those used by shell-forward-word.
3353 shell-backward-kill-word (M-Rubout)
3354 Kill the word behind point. Word boundaries are the same as
3355 those used by shell-backward-word.
3356 unix-word-rubout (C-w)
3357 Kill the word behind point, using white space as a word boundâ€
3358 ary. The killed text is saved on the kill-ring.
3359 unix-filename-rubout
3360 Kill the word behind point, using white space and the slash
3361 character as the word boundaries. The killed text is saved on
3362 the kill-ring.
3363 delete-horizontal-space (M-\)
3364 Delete all spaces and tabs around point.
3365 kill-region
3366 Kill the text in the current region.
3367 copy-region-as-kill
3368 Copy the text in the region to the kill buffer.
3369 copy-backward-word
3370 Copy the word before point to the kill buffer. The word boundâ€
3371 aries are the same as backward-word.
3372 copy-forward-word
3373 Copy the word following point to the kill buffer. The word
3374 boundaries are the same as forward-word.
3375 yank (C-y)
3376 Yank the top of the kill ring into the buffer at point.
3377 yank-pop (M-y)
3378 Rotate the kill ring, and yank the new top. Only works followâ€
3379 ing yank or yank-pop.
3380
3381 Numeric Arguments
3382 digit-argument (M-0, M-1, ..., M--)
3383 Add this digit to the argument already accumulating, or start a
3384 new argument. M-- starts a negative argument.
3385 universal-argument
3386 This is another way to specify an argument. If this command is
3387 followed by one or more digits, optionally with a leading minus
3388 sign, those digits define the argument. If the command is folâ€
3389 lowed by digits, executing universal-argument again ends the
3390 numeric argument, but is otherwise ignored. As a special case,
3391 if this command is immediately followed by a character that is
3392 neither a digit or minus sign, the argument count for the next
3393 command is multiplied by four. The argument count is initially
3394 one, so executing this function the first time makes the arguâ€
3395 ment count four, a second time makes the argument count sixteen,
3396 and so on.
3397
3398 Completing
3399 complete (TAB)
3400 Attempt to perform completion on the text before point. Bash
3401 attempts completion treating the text as a variable (if the text
3402 begins with $), username (if the text begins with ~), hostname
3403 (if the text begins with @), or command (including aliases and
3404 functions) in turn. If none of these produces a match, filename
3405 completion is attempted.
3406 possible-completions (M-?)
3407 List the possible completions of the text before point.
3408 insert-completions (M-*)
3409 Insert all completions of the text before point that would have
3410 been generated by possible-completions.
3411 menu-complete
3412 Similar to complete, but replaces the word to be completed with
3413 a single match from the list of possible completions. Repeated
3414 execution of menu-complete steps through the list of possible
3415 completions, inserting each match in turn. At the end of the
3416 list of completions, the bell is rung (subject to the setting of
3417 bell-style) and the original text is restored. An argument of n
3418 moves n positions forward in the list of matches; a negative
3419 argument may be used to move backward through the list. This
3420 command is intended to be bound to TAB, but is unbound by
3421 default.
3422 menu-complete-backward
3423 Identical to menu-complete, but moves backward through the list
3424 of possible completions, as if menu-complete had been given a
3425 negative argument. This command is unbound by default.
3426 delete-char-or-list
3427 Deletes the character under the cursor if not at the beginning
3428 or end of the line (like delete-char). If at the end of the
3429 line, behaves identically to possible-completions. This command
3430 is unbound by default.
3431 complete-filename (M-/)
3432 Attempt filename completion on the text before point.
3433 possible-filename-completions (C-x /)
3434 List the possible completions of the text before point, treating
3435 it as a filename.
3436 complete-username (M-~)
3437 Attempt completion on the text before point, treating it as a
3438 username.
3439 possible-username-completions (C-x ~)
3440 List the possible completions of the text before point, treating
3441 it as a username.
3442 complete-variable (M-$)
3443 Attempt completion on the text before point, treating it as a
3444 shell variable.
3445 possible-variable-completions (C-x $)
3446 List the possible completions of the text before point, treating
3447 it as a shell variable.
3448 complete-hostname (M-@)
3449 Attempt completion on the text before point, treating it as a
3450 hostname.
3451 possible-hostname-completions (C-x @)
3452 List the possible completions of the text before point, treating
3453 it as a hostname.
3454 complete-command (M-!)
3455 Attempt completion on the text before point, treating it as a
3456 command name. Command completion attempts to match the text
3457 against aliases, reserved words, shell functions, shell
3458 builtins, and finally executable filenames, in that order.
3459 possible-command-completions (C-x !)
3460 List the possible completions of the text before point, treating
3461 it as a command name.
3462 dynamic-complete-history (M-TAB)
3463 Attempt completion on the text before point, comparing the text
3464 against lines from the history list for possible completion
3465 matches.
3466 dabbrev-expand
3467 Attempt menu completion on the text before point, comparing the
3468 text against lines from the history list for possible completion
3469 matches.
3470 complete-into-braces (M-{)
3471 Perform filename completion and insert the list of possible comâ€
3472 pletions enclosed within braces so the list is available to the
3473 shell (see Brace Expansion above).
3474
3475 Keyboard Macros
3476 start-kbd-macro (C-x ()
3477 Begin saving the characters typed into the current keyboard
3478 macro.
3479 end-kbd-macro (C-x ))
3480 Stop saving the characters typed into the current keyboard macro
3481 and store the definition.
3482 call-last-kbd-macro (C-x e)
3483 Re-execute the last keyboard macro defined, by making the charâ€
3484 acters in the macro appear as if typed at the keyboard.
3485 print-last-kbd-macro ()
3486 Print the last keyboard macro defined in a format suitable for
3487 the inputrc file.
3488
3489 Miscellaneous
3490 re-read-init-file (C-x C-r)
3491 Read in the contents of the inputrc file, and incorporate any
3492 bindings or variable assignments found there.
3493 abort (C-g)
3494 Abort the current editing command and ring the terminal's bell
3495 (subject to the setting of bell-style).
3496 do-uppercase-version (M-a, M-b, M-x, ...)
3497 If the metafied character x is lowercase, run the command that
3498 is bound to the corresponding uppercase character.
3499 prefix-meta (ESC)
3500 Metafy the next character typed. ESC f is equivalent to Meta-f.
3501 undo (C-_, C-x C-u)
3502 Incremental undo, separately remembered for each line.
3503 revert-line (M-r)
3504 Undo all changes made to this line. This is like executing the
3505 undo command enough times to return the line to its initial
3506 state.
3507 tilde-expand (M-&)
3508 Perform tilde expansion on the current word.
3509 set-mark (C-@, M-<space>)
3510 Set the mark to the point. If a numeric argument is supplied,
3511 the mark is set to that position.
3512 exchange-point-and-mark (C-x C-x)
3513 Swap the point with the mark. The current cursor position is
3514 set to the saved position, and the old cursor position is saved
3515 as the mark.
3516 character-search (C-])
3517 A character is read and point is moved to the next occurrence of
3518 that character. A negative count searches for previous occurâ€
3519 rences.
3520 character-search-backward (M-C-])
3521 A character is read and point is moved to the previous occurâ€
3522 rence of that character. A negative count searches for subseâ€
3523 quent occurrences.
3524 skip-csi-sequence
3525 Read enough characters to consume a multi-key sequence such as
3526 those defined for keys like Home and End. Such sequences begin
3527 with a Control Sequence Indicator (CSI), usually ESC-[. If this
3528 sequence is bound to "\[", keys producing such sequences will
3529 have no effect unless explicitly bound to a readline command,
3530 instead of inserting stray characters into the editing buffer.
3531 This is unbound by default, but usually bound to ESC-[.
3532 insert-comment (M-#)
3533 Without a numeric argument, the value of the readline comâ€
3534 ment-begin variable is inserted at the beginning of the current
3535 line. If a numeric argument is supplied, this command acts as a
3536 toggle: if the characters at the beginning of the line do not
3537 match the value of comment-begin, the value is inserted, otherâ€
3538 wise the characters in comment-begin are deleted from the beginâ€
3539 ning of the line. In either case, the line is accepted as if a
3540 newline had been typed. The default value of comment-begin
3541 causes this command to make the current line a shell comment.
3542 If a numeric argument causes the comment character to be
3543 removed, the line will be executed by the shell.
3544 glob-complete-word (M-g)
3545 The word before point is treated as a pattern for pathname
3546 expansion, with an asterisk implicitly appended. This pattern
3547 is used to generate a list of matching filenames for possible
3548 completions.
3549 glob-expand-word (C-x *)
3550 The word before point is treated as a pattern for pathname
3551 expansion, and the list of matching filenames is inserted,
3552 replacing the word. If a numeric argument is supplied, an
3553 asterisk is appended before pathname expansion.
3554 glob-list-expansions (C-x g)
3555 The list of expansions that would have been generated by
3556 glob-expand-word is displayed, and the line is redrawn. If a
3557 numeric argument is supplied, an asterisk is appended before
3558 pathname expansion.
3559 dump-functions
3560 Print all of the functions and their key bindings to the readâ€
3561 line output stream. If a numeric argument is supplied, the outâ€
3562 put is formatted in such a way that it can be made part of an
3563 inputrc file.
3564 dump-variables
3565 Print all of the settable readline variables and their values to
3566 the readline output stream. If a numeric argument is supplied,
3567 the output is formatted in such a way that it can be made part
3568 of an inputrc file.
3569 dump-macros
3570 Print all of the readline key sequences bound to macros and the
3571 strings they output. If a numeric argument is supplied, the
3572 output is formatted in such a way that it can be made part of an
3573 inputrc file.
3574 display-shell-version (C-x C-v)
3575 Display version information about the current instance of bash.
3576
3577 Programmable Completion
3578 When word completion is attempted for an argument to a command for
3579 which a completion specification (a compspec) has been defined using
3580 the complete builtin (see SHELL BUILTIN COMMANDS below), the programâ€
3581 mable completion facilities are invoked.
3582
3583 First, the command name is identified. If the command word is the
3584 empty string (completion attempted at the beginning of an empty line),
3585 any compspec defined with the -E option to complete is used. If a
3586 compspec has been defined for that command, the compspec is used to
3587 generate the list of possible completions for the word. If the command
3588 word is a full pathname, a compspec for the full pathname is searched
3589 for first. If no compspec is found for the full pathname, an attempt
3590 is made to find a compspec for the portion following the final slash.
3591 If those searches do not result in a compspec, any compspec defined
3592 with the -D option to complete is used as the default.
3593
3594 Once a compspec has been found, it is used to generate the list of
3595 matching words. If a compspec is not found, the default bash compleâ€
3596 tion as described above under Completing is performed.
3597
3598 First, the actions specified by the compspec are used. Only matches
3599 which are prefixed by the word being completed are returned. When the
3600 -f or -d option is used for filename or directory name completion, the
3601 shell variable FIGNORE is used to filter the matches.
3602
3603 Any completions specified by a pathname expansion pattern to the -G
3604 option are generated next. The words generated by the pattern need not
3605 match the word being completed. The GLOBIGNORE shell variable is not
3606 used to filter the matches, but the FIGNORE variable is used.
3607
3608 Next, the string specified as the argument to the -W option is considâ€
3609 ered. The string is first split using the characters in the IFS speâ€
3610 cial variable as delimiters. Shell quoting is honored. Each word is
3611 then expanded using brace expansion, tilde expansion, parameter and
3612 variable expansion, command substitution, and arithmetic expansion, as
3613 described above under EXPANSION. The results are split using the rules
3614 described above under Word Splitting. The results of the expansion are
3615 prefix-matched against the word being completed, and the matching words
3616 become the possible completions.
3617
3618 After these matches have been generated, any shell function or command
3619 specified with the -F and -C options is invoked. When the command or
3620 function is invoked, the COMP_LINE, COMP_POINT, COMP_KEY, and COMP_TYPE
3621 variables are assigned values as described above under Shell Variables.
3622 If a shell function is being invoked, the COMP_WORDS and COMP_CWORD
3623 variables are also set. When the function or command is invoked, the
3624 first argument ($1) is the name of the command whose arguments are
3625 being completed, the second argument ($2) is the word being completed,
3626 and the third argument ($3) is the word preceding the word being comâ€
3627 pleted on the current command line. No filtering of the generated comâ€
3628 pletions against the word being completed is performed; the function or
3629 command has complete freedom in generating the matches.
3630
3631 Any function specified with -F is invoked first. The function may use
3632 any of the shell facilities, including the compgen builtin described
3633 below, to generate the matches. It must put the possible completions
3634 in the COMPREPLY array variable, one per array element.
3635
3636 Next, any command specified with the -C option is invoked in an enviâ€
3637 ronment equivalent to command substitution. It should print a list of
3638 completions, one per line, to the standard output. Backslash may be
3639 used to escape a newline, if necessary.
3640
3641 After all of the possible completions are generated, any filter speciâ€
3642 fied with the -X option is applied to the list. The filter is a patâ€
3643 tern as used for pathname expansion; a & in the pattern is replaced
3644 with the text of the word being completed. A literal & may be escaped
3645 with a backslash; the backslash is removed before attempting a match.
3646 Any completion that matches the pattern will be removed from the list.
3647 A leading ! negates the pattern; in this case any completion not matchâ€
3648 ing the pattern will be removed.
3649
3650 Finally, any prefix and suffix specified with the -P and -S options are
3651 added to each member of the completion list, and the result is returned
3652 to the readline completion code as the list of possible completions.
3653
3654 If the previously-applied actions do not generate any matches, and the
3655 -o dirnames option was supplied to complete when the compspec was
3656 defined, directory name completion is attempted.
3657
3658 If the -o plusdirs option was supplied to complete when the compspec
3659 was defined, directory name completion is attempted and any matches are
3660 added to the results of the other actions.
3661
3662 By default, if a compspec is found, whatever it generates is returned
3663 to the completion code as the full set of possible completions. The
3664 default bash completions are not attempted, and the readline default of
3665 filename completion is disabled. If the -o bashdefault option was supâ€
3666 plied to complete when the compspec was defined, the bash default comâ€
3667 pletions are attempted if the compspec generates no matches. If the -o
3668 default option was supplied to complete when the compspec was defined,
3669 readline's default completion will be performed if the compspec (and,
3670 if attempted, the default bash completions) generate no matches.
3671
3672 When a compspec indicates that directory name completion is desired,
3673 the programmable completion functions force readline to append a slash
3674 to completed names which are symbolic links to directories, subject to
3675 the value of the mark-directories readline variable, regardless of the
3676 setting of the mark-symlinked-directories readline variable.
3677
3678 There is some support for dynamically modifying completions. This is
3679 most useful when used in combination with a default completion speciâ€
3680 fied with complete -D. It's possible for shell functions executed as
3681 completion handlers to indicate that completion should be retried by
3682 returning an exit status of 124. If a shell function returns 124, and
3683 changes the compspec associated with the command on which completion is
3684 being attempted (supplied as the first argument when the function is
3685 executed), programmable completion restarts from the beginning, with an
3686 attempt to find a new compspec for that command. This allows a set of
3687 completions to be built dynamically as completion is attempted, rather
3688 than being loaded all at once.
3689
3690 For instance, assuming that there is a library of compspecs, each kept
3691 in a file corresponding to the name of the command, the following
3692 default completion function would load completions dynamically:
3693
3694 _completion_loader()
3695 {
3696 . "/etc/bash_completion.d/$1.sh" >/dev/null 2>&1 && return 124
3697 }
3698 complete -D -F _completion_loader -o bashdefault -o default
3699
3700HISTORY
3701 When the -o history option to the set builtin is enabled, the shell
3702 provides access to the command history, the list of commands previously
3703 typed. The value of the HISTSIZE variable is used as the number of
3704 commands to save in a history list. The text of the last HISTSIZE comâ€
3705 mands (default 500) is saved. The shell stores each command in the
3706 history list prior to parameter and variable expansion (see EXPANSION
3707 above) but after history expansion is performed, subject to the values
3708 of the shell variables HISTIGNORE and HISTCONTROL.
3709
3710 On startup, the history is initialized from the file named by the variâ€
3711 able HISTFILE (default ~/.bash_history). The file named by the value
3712 of HISTFILE is truncated, if necessary, to contain no more than the
3713 number of lines specified by the value of HISTFILESIZE. If HISTFILEâ€
3714 SIZE is unset, or set to null, a non-numeric value, or a numeric value
3715 less than zero, the history file is not truncated. When the history
3716 file is read, lines beginning with the history comment character folâ€
3717 lowed immediately by a digit are interpreted as timestamps for the preâ€
3718 ceding history line. These timestamps are optionally displayed dependâ€
3719 ing on the value of the HISTTIMEFORMAT variable. When a shell with
3720 history enabled exits, the last $HISTSIZE lines are copied from the
3721 history list to $HISTFILE. If the histappend shell option is enabled
3722 (see the description of shopt under SHELL BUILTIN COMMANDS below), the
3723 lines are appended to the history file, otherwise the history file is
3724 overwritten. If HISTFILE is unset, or if the history file is
3725 unwritable, the history is not saved. If the HISTTIMEFORMAT variable
3726 is set, time stamps are written to the history file, marked with the
3727 history comment character, so they may be preserved across shell sesâ€
3728 sions. This uses the history comment character to distinguish timeâ€
3729 stamps from other history lines. After saving the history, the history
3730 file is truncated to contain no more than HISTFILESIZE lines. If HISTâ€
3731 FILESIZE is unset, or set to null, a non-numeric value, or a numeric
3732 value less than zero, the history file is not truncated.
3733
3734 The builtin command fc (see SHELL BUILTIN COMMANDS below) may be used
3735 to list or edit and re-execute a portion of the history list. The hisâ€
3736 tory builtin may be used to display or modify the history list and
3737 manipulate the history file. When using command-line editing, search
3738 commands are available in each editing mode that provide access to the
3739 history list.
3740
3741 The shell allows control over which commands are saved on the history
3742 list. The HISTCONTROL and HISTIGNORE variables may be set to cause the
3743 shell to save only a subset of the commands entered. The cmdhist shell
3744 option, if enabled, causes the shell to attempt to save each line of a
3745 multi-line command in the same history entry, adding semicolons where
3746 necessary to preserve syntactic correctness. The lithist shell option
3747 causes the shell to save the command with embedded newlines instead of
3748 semicolons. See the description of the shopt builtin below under SHELL
3749 BUILTIN COMMANDS for information on setting and unsetting shell
3750 options.
3751
3752HISTORY EXPANSION
3753 The shell supports a history expansion feature that is similar to the
3754 history expansion in csh. This section describes what syntax features
3755 are available. This feature is enabled by default for interactive
3756 shells, and can be disabled using the +H option to the set builtin comâ€
3757 mand (see SHELL BUILTIN COMMANDS below). Non-interactive shells do not
3758 perform history expansion by default.
3759
3760 History expansions introduce words from the history list into the input
3761 stream, making it easy to repeat commands, insert the arguments to a
3762 previous command into the current input line, or fix errors in previous
3763 commands quickly.
3764
3765 History expansion is performed immediately after a complete line is
3766 read, before the shell breaks it into words. It takes place in two
3767 parts. The first is to determine which line from the history list to
3768 use during substitution. The second is to select portions of that line
3769 for inclusion into the current one. The line selected from the history
3770 is the event, and the portions of that line that are acted upon are
3771 words. Various modifiers are available to manipulate the selected
3772 words. The line is broken into words in the same fashion as when readâ€
3773 ing input, so that several metacharacter-separated words surrounded by
3774 quotes are considered one word. History expansions are introduced by
3775 the appearance of the history expansion character, which is ! by
3776 default. Only backslash (\) and single quotes can quote the history
3777 expansion character.
3778
3779 Several characters inhibit history expansion if found immediately folâ€
3780 lowing the history expansion character, even if it is unquoted: space,
3781 tab, newline, carriage return, and =. If the extglob shell option is
3782 enabled, ( will also inhibit expansion.
3783
3784 Several shell options settable with the shopt builtin may be used to
3785 tailor the behavior of history expansion. If the histverify shell
3786 option is enabled (see the description of the shopt builtin below), and
3787 readline is being used, history substitutions are not immediately
3788 passed to the shell parser. Instead, the expanded line is reloaded
3789 into the readline editing buffer for further modification. If readline
3790 is being used, and the histreedit shell option is enabled, a failed
3791 history substitution will be reloaded into the readline editing buffer
3792 for correction. The -p option to the history builtin command may be
3793 used to see what a history expansion will do before using it. The -s
3794 option to the history builtin may be used to add commands to the end of
3795 the history list without actually executing them, so that they are
3796 available for subsequent recall.
3797
3798 The shell allows control of the various characters used by the history
3799 expansion mechanism (see the description of histchars above under Shell
3800 Variables). The shell uses the history comment character to mark hisâ€
3801 tory timestamps when writing the history file.
3802
3803 Event Designators
3804 An event designator is a reference to a command line entry in the hisâ€
3805 tory list. Unless the reference is absolute, events are relative to
3806 the current position in the history list.
3807
3808 ! Start a history substitution, except when followed by a blank,
3809 newline, carriage return, = or ( (when the extglob shell option
3810 is enabled using the shopt builtin).
3811 !n Refer to command line n.
3812 !-n Refer to the current command minus n.
3813 !! Refer to the previous command. This is a synonym for `!-1'.
3814 !string
3815 Refer to the most recent command preceding the current position
3816 in the history list starting with string.
3817 !?string[?]
3818 Refer to the most recent command preceding the current position
3819 in the history list containing string. The trailing ? may be
3820 omitted if string is followed immediately by a newline.
3821 ^string1^string2^
3822 Quick substitution. Repeat the previous command, replacing
3823 string1 with string2. Equivalent to ``!!:s/string1/string2/''
3824 (see Modifiers below).
3825 !# The entire command line typed so far.
3826
3827 Word Designators
3828 Word designators are used to select desired words from the event. A :
3829 separates the event specification from the word designator. It may be
3830 omitted if the word designator begins with a ^, $, *, -, or %. Words
3831 are numbered from the beginning of the line, with the first word being
3832 denoted by 0 (zero). Words are inserted into the current line sepaâ€
3833 rated by single spaces.
3834
3835 0 (zero)
3836 The zeroth word. For the shell, this is the command word.
3837 n The nth word.
3838 ^ The first argument. That is, word 1.
3839 $ The last word. This is usually the last argument, but will
3840 expand to the zeroth word if there is only one word in the line.
3841 % The word matched by the most recent `?string?' search.
3842 x-y A range of words; `-y' abbreviates `0-y'.
3843 * All of the words but the zeroth. This is a synonym for `1-$'.
3844 It is not an error to use * if there is just one word in the
3845 event; the empty string is returned in that case.
3846 x* Abbreviates x-$.
3847 x- Abbreviates x-$ like x*, but omits the last word.
3848
3849 If a word designator is supplied without an event specification, the
3850 previous command is used as the event.
3851
3852 Modifiers
3853 After the optional word designator, there may appear a sequence of one
3854 or more of the following modifiers, each preceded by a `:'.
3855
3856 h Remove a trailing filename component, leaving only the head.
3857 t Remove all leading filename components, leaving the tail.
3858 r Remove a trailing suffix of the form .xxx, leaving the basename.
3859 e Remove all but the trailing suffix.
3860 p Print the new command but do not execute it.
3861 q Quote the substituted words, escaping further substitutions.
3862 x Quote the substituted words as with q, but break into words at
3863 blanks and newlines.
3864 s/old/new/
3865 Substitute new for the first occurrence of old in the event
3866 line. Any delimiter can be used in place of /. The final
3867 delimiter is optional if it is the last character of the event
3868 line. The delimiter may be quoted in old and new with a single
3869 backslash. If & appears in new, it is replaced by old. A sinâ€
3870 gle backslash will quote the &. If old is null, it is set to
3871 the last old substituted, or, if no previous history substituâ€
3872 tions took place, the last string in a !?string[?] search.
3873 & Repeat the previous substitution.
3874 g Cause changes to be applied over the entire event line. This is
3875 used in conjunction with `:s' (e.g., `:gs/old/new/') or `:&'.
3876 If used with `:s', any delimiter can be used in place of /, and
3877 the final delimiter is optional if it is the last character of
3878 the event line. An a may be used as a synonym for g.
3879 G Apply the following `s' modifier once to each word in the event
3880 line.
3881
3882SHELL BUILTIN COMMANDS
3883 Unless otherwise noted, each builtin command documented in this section
3884 as accepting options preceded by - accepts -- to signify the end of the
3885 options. The :, true, false, and test builtins do not accept options
3886 and do not treat -- specially. The exit, logout, break, continue, let,
3887 and shift builtins accept and process arguments beginning with - withâ€
3888 out requiring --. Other builtins that accept arguments but are not
3889 specified as accepting options interpret arguments beginning with - as
3890 invalid options and require -- to prevent this interpretation.
3891 : [arguments]
3892 No effect; the command does nothing beyond expanding arguments
3893 and performing any specified redirections. A zero exit code is
3894 returned.
3895
3896 . filename [arguments]
3897 source filename [arguments]
3898 Read and execute commands from filename in the current shell
3899 environment and return the exit status of the last command exeâ€
3900 cuted from filename. If filename does not contain a slash,
3901 filenames in PATH are used to find the directory containing
3902 filename. The file searched for in PATH need not be executable.
3903 When bash is not in posix mode, the current directory is
3904 searched if no file is found in PATH. If the sourcepath option
3905 to the shopt builtin command is turned off, the PATH is not
3906 searched. If any arguments are supplied, they become the posiâ€
3907 tional parameters when filename is executed. Otherwise the
3908 positional parameters are unchanged. The return status is the
3909 status of the last command exited within the script (0 if no
3910 commands are executed), and false if filename is not found or
3911 cannot be read.
3912
3913 alias [-p] [name[=value] ...]
3914 Alias with no arguments or with the -p option prints the list of
3915 aliases in the form alias name=value on standard output. When
3916 arguments are supplied, an alias is defined for each name whose
3917 value is given. A trailing space in value causes the next word
3918 to be checked for alias substitution when the alias is expanded.
3919 For each name in the argument list for which no value is supâ€
3920 plied, the name and value of the alias is printed. Alias
3921 returns true unless a name is given for which no alias has been
3922 defined.
3923
3924 bg [jobspec ...]
3925 Resume each suspended job jobspec in the background, as if it
3926 had been started with &. If jobspec is not present, the shell's
3927 notion of the current job is used. bg jobspec returns 0 unless
3928 run when job control is disabled or, when run with job control
3929 enabled, any specified jobspec was not found or was started
3930 without job control.
3931
3932 bind [-m keymap] [-lpsvPSVX]
3933 bind [-m keymap] [-q function] [-u function] [-r keyseq]
3934 bind [-m keymap] -f filename
3935 bind [-m keymap] -x keyseq:shell-command
3936 bind [-m keymap] keyseq:function-name
3937 bind readline-command
3938 Display current readline key and function bindings, bind a key
3939 sequence to a readline function or macro, or set a readline
3940 variable. Each non-option argument is a command as it would
3941 appear in .inputrc, but each binding or command must be passed
3942 as a separate argument; e.g., '"\C-x\C-r": re-read-init-file'.
3943 Options, if supplied, have the following meanings:
3944 -m keymap
3945 Use keymap as the keymap to be affected by the subsequent
3946 bindings. Acceptable keymap names are emacs, emacs-stanâ€
3947 dard, emacs-meta, emacs-ctlx, vi, vi-move, vi-command,
3948 and vi-insert. vi is equivalent to vi-command; emacs is
3949 equivalent to emacs-standard.
3950 -l List the names of all readline functions.
3951 -p Display readline function names and bindings in such a
3952 way that they can be re-read.
3953 -P List current readline function names and bindings.
3954 -s Display readline key sequences bound to macros and the
3955 strings they output in such a way that they can be re-
3956 read.
3957 -S Display readline key sequences bound to macros and the
3958 strings they output.
3959 -v Display readline variable names and values in such a way
3960 that they can be re-read.
3961 -V List current readline variable names and values.
3962 -f filename
3963 Read key bindings from filename.
3964 -q function
3965 Query about which keys invoke the named function.
3966 -u function
3967 Unbind all keys bound to the named function.
3968 -r keyseq
3969 Remove any current binding for keyseq.
3970 -x keyseq:shell-command
3971 Cause shell-command to be executed whenever keyseq is
3972 entered. When shell-command is executed, the shell sets
3973 the READLINE_LINE variable to the contents of the readâ€
3974 line line buffer and the READLINE_POINT variable to the
3975 current location of the insertion point. If the executed
3976 command changes the value of READLINE_LINE or READâ€
3977 LINE_POINT, those new values will be reflected in the
3978 editing state.
3979 -X List all key sequences bound to shell commands and the
3980 associated commands in a format that can be reused as
3981 input.
3982
3983 The return value is 0 unless an unrecognized option is given or
3984 an error occurred.
3985
3986 break [n]
3987 Exit from within a for, while, until, or select loop. If n is
3988 specified, break n levels. n must be ≥ 1. If n is greater than
3989 the number of enclosing loops, all enclosing loops are exited.
3990 The return value is 0 unless n is not greater than or equal to
3991 1.
3992
3993 builtin shell-builtin [arguments]
3994 Execute the specified shell builtin, passing it arguments, and
3995 return its exit status. This is useful when defining a function
3996 whose name is the same as a shell builtin, retaining the funcâ€
3997 tionality of the builtin within the function. The cd builtin is
3998 commonly redefined this way. The return status is false if
3999 shell-builtin is not a shell builtin command.
4000
4001 caller [expr]
4002 Returns the context of any active subroutine call (a shell funcâ€
4003 tion or a script executed with the . or source builtins). Withâ€
4004 out expr, caller displays the line number and source filename of
4005 the current subroutine call. If a non-negative integer is supâ€
4006 plied as expr, caller displays the line number, subroutine name,
4007 and source file corresponding to that position in the current
4008 execution call stack. This extra information may be used, for
4009 example, to print a stack trace. The current frame is frame 0.
4010 The return value is 0 unless the shell is not executing a subâ€
4011 routine call or expr does not correspond to a valid position in
4012 the call stack.
4013
4014 cd [-L|[-P [-e]] [-@]] [dir]
4015 Change the current directory to dir. if dir is not supplied,
4016 the value of the HOME shell variable is the default. Any addiâ€
4017 tional arguments following dir are ignored. The variable CDPATH
4018 defines the search path for the directory containing dir: each
4019 directory name in CDPATH is searched for dir. Alternative
4020 directory names in CDPATH are separated by a colon (:). A null
4021 directory name in CDPATH is the same as the current directory,
4022 i.e., ``.''. If dir begins with a slash (/), then CDPATH is not
4023 used. The -P option causes cd to use the physical directory
4024 structure by resolving symbolic links while traversing dir and
4025 before processing instances of .. in dir (see also the -P option
4026 to the set builtin command); the -L option forces symbolic links
4027 to be followed by resolving the link after processing instances
4028 of .. in dir. If .. appears in dir, it is processed by removing
4029 the immediately previous pathname component from dir, back to a
4030 slash or the beginning of dir. If the -e option is supplied
4031 with -P, and the current working directory cannot be successâ€
4032 fully determined after a successful directory change, cd will
4033 return an unsuccessful status. On systems that support it, the
4034 -@ option presents the extended attributes associated with a
4035 file as a directory. An argument of - is converted to $OLDPWD
4036 before the directory change is attempted. If a non-empty direcâ€
4037 tory name from CDPATH is used, or if - is the first argument,
4038 and the directory change is successful, the absolute pathname of
4039 the new working directory is written to the standard output.
4040 The return value is true if the directory was successfully
4041 changed; false otherwise.
4042
4043 command [-pVv] command [arg ...]
4044 Run command with args suppressing the normal shell function
4045 lookup. Only builtin commands or commands found in the PATH are
4046 executed. If the -p option is given, the search for command is
4047 performed using a default value for PATH that is guaranteed to
4048 find all of the standard utilities. If either the -V or -v
4049 option is supplied, a description of command is printed. The -v
4050 option causes a single word indicating the command or filename
4051 used to invoke command to be displayed; the -V option produces a
4052 more verbose description. If the -V or -v option is supplied,
4053 the exit status is 0 if command was found, and 1 if not. If
4054 neither option is supplied and an error occurred or command canâ€
4055 not be found, the exit status is 127. Otherwise, the exit staâ€
4056 tus of the command builtin is the exit status of command.
4057
4058 compgen [option] [word]
4059 Generate possible completion matches for word according to the
4060 options, which may be any option accepted by the complete
4061 builtin with the exception of -p and -r, and write the matches
4062 to the standard output. When using the -F or -C options, the
4063 various shell variables set by the programmable completion
4064 facilities, while available, will not have useful values.
4065
4066 The matches will be generated in the same way as if the programâ€
4067 mable completion code had generated them directly from a compleâ€
4068 tion specification with the same flags. If word is specified,
4069 only those completions matching word will be displayed.
4070
4071 The return value is true unless an invalid option is supplied,
4072 or no matches were generated.
4073
4074 complete [-abcdefgjksuv] [-o comp-option] [-DE] [-A action] [-G globâ€
4075 pat] [-W wordlist] [-F function] [-C command]
4076 [-X filterpat] [-P prefix] [-S suffix] name [name ...]
4077 complete -pr [-DE] [name ...]
4078 Specify how arguments to each name should be completed. If the
4079 -p option is supplied, or if no options are supplied, existing
4080 completion specifications are printed in a way that allows them
4081 to be reused as input. The -r option removes a completion specâ€
4082 ification for each name, or, if no names are supplied, all comâ€
4083 pletion specifications. The -D option indicates that the
4084 remaining options and actions should apply to the ``default''
4085 command completion; that is, completion attempted on a command
4086 for which no completion has previously been defined. The -E
4087 option indicates that the remaining options and actions should
4088 apply to ``empty'' command completion; that is, completion
4089 attempted on a blank line.
4090
4091 The process of applying these completion specifications when
4092 word completion is attempted is described above under Programâ€
4093 mable Completion.
4094
4095 Other options, if specified, have the following meanings. The
4096 arguments to the -G, -W, and -X options (and, if necessary, the
4097 -P and -S options) should be quoted to protect them from expanâ€
4098 sion before the complete builtin is invoked.
4099 -o comp-option
4100 The comp-option controls several aspects of the compâ€
4101 spec's behavior beyond the simple generation of compleâ€
4102 tions. comp-option may be one of:
4103 bashdefault
4104 Perform the rest of the default bash completions
4105 if the compspec generates no matches.
4106 default Use readline's default filename completion if
4107 the compspec generates no matches.
4108 dirnames
4109 Perform directory name completion if the compâ€
4110 spec generates no matches.
4111 filenames
4112 Tell readline that the compspec generates fileâ€
4113 names, so it can perform any filename-specific
4114 processing (like adding a slash to directory
4115 names, quoting special characters, or suppressâ€
4116 ing trailing spaces). Intended to be used with
4117 shell functions.
4118 noquote Tell readline not to quote the completed words
4119 if they are filenames (quoting filenames is the
4120 default).
4121 nospace Tell readline not to append a space (the
4122 default) to words completed at the end of the
4123 line.
4124 plusdirs
4125 After any matches defined by the compspec are
4126 generated, directory name completion is
4127 attempted and any matches are added to the
4128 results of the other actions.
4129 -A action
4130 The action may be one of the following to generate a
4131 list of possible completions:
4132 alias Alias names. May also be specified as -a.
4133 arrayvar
4134 Array variable names.
4135 binding Readline key binding names.
4136 builtin Names of shell builtin commands. May also be
4137 specified as -b.
4138 command Command names. May also be specified as -c.
4139 directory
4140 Directory names. May also be specified as -d.
4141 disabled
4142 Names of disabled shell builtins.
4143 enabled Names of enabled shell builtins.
4144 export Names of exported shell variables. May also be
4145 specified as -e.
4146 file File names. May also be specified as -f.
4147 function
4148 Names of shell functions.
4149 group Group names. May also be specified as -g.
4150 helptopic
4151 Help topics as accepted by the help builtin.
4152 hostname
4153 Hostnames, as taken from the file specified by
4154 the HOSTFILE shell variable.
4155 job Job names, if job control is active. May also
4156 be specified as -j.
4157 keyword Shell reserved words. May also be specified as
4158 -k.
4159 running Names of running jobs, if job control is active.
4160 service Service names. May also be specified as -s.
4161 setopt Valid arguments for the -o option to the set
4162 builtin.
4163 shopt Shell option names as accepted by the shopt
4164 builtin.
4165 signal Signal names.
4166 stopped Names of stopped jobs, if job control is active.
4167 user User names. May also be specified as -u.
4168 variable
4169 Names of all shell variables. May also be specâ€
4170 ified as -v.
4171 -C command
4172 command is executed in a subshell environment, and its
4173 output is used as the possible completions.
4174 -F function
4175 The shell function function is executed in the current
4176 shell environment. When the function is executed, the
4177 first argument ($1) is the name of the command whose
4178 arguments are being completed, the second argument ($2)
4179 is the word being completed, and the third argument ($3)
4180 is the word preceding the word being completed on the
4181 current command line. When it finishes, the possible
4182 completions are retrieved from the value of the COMPREâ€
4183 PLY array variable.
4184 -G globpat
4185 The pathname expansion pattern globpat is expanded to
4186 generate the possible completions.
4187 -P prefix
4188 prefix is added at the beginning of each possible comâ€
4189 pletion after all other options have been applied.
4190 -S suffix
4191 suffix is appended to each possible completion after all
4192 other options have been applied.
4193 -W wordlist
4194 The wordlist is split using the characters in the IFS
4195 special variable as delimiters, and each resultant word
4196 is expanded. The possible completions are the members
4197 of the resultant list which match the word being comâ€
4198 pleted.
4199 -X filterpat
4200 filterpat is a pattern as used for pathname expansion.
4201 It is applied to the list of possible completions generâ€
4202 ated by the preceding options and arguments, and each
4203 completion matching filterpat is removed from the list.
4204 A leading ! in filterpat negates the pattern; in this
4205 case, any completion not matching filterpat is removed.
4206
4207 The return value is true unless an invalid option is supplied,
4208 an option other than -p or -r is supplied without a name arguâ€
4209 ment, an attempt is made to remove a completion specification
4210 for a name for which no specification exists, or an error occurs
4211 adding a completion specification.
4212
4213 compopt [-o option] [-DE] [+o option] [name]
4214 Modify completion options for each name according to the
4215 options, or for the currently-executing completion if no names
4216 are supplied. If no options are given, display the completion
4217 options for each name or the current completion. The possible
4218 values of option are those valid for the complete builtin
4219 described above. The -D option indicates that the remaining
4220 options should apply to the ``default'' command completion; that
4221 is, completion attempted on a command for which no completion
4222 has previously been defined. The -E option indicates that the
4223 remaining options should apply to ``empty'' command completion;
4224 that is, completion attempted on a blank line.
4225
4226 The return value is true unless an invalid option is supplied,
4227 an attempt is made to modify the options for a name for which no
4228 completion specification exists, or an output error occurs.
4229
4230 continue [n]
4231 Resume the next iteration of the enclosing for, while, until, or
4232 select loop. If n is specified, resume at the nth enclosing
4233 loop. n must be ≥ 1. If n is greater than the number of
4234 enclosing loops, the last enclosing loop (the ``top-level''
4235 loop) is resumed. The return value is 0 unless n is not greater
4236 than or equal to 1.
4237
4238 declare [-aAfFgilnrtux] [-p] [name[=value] ...]
4239 typeset [-aAfFgilnrtux] [-p] [name[=value] ...]
4240 Declare variables and/or give them attributes. If no names are
4241 given then display the values of variables. The -p option will
4242 display the attributes and values of each name. When -p is used
4243 with name arguments, additional options, other than -f and -F,
4244 are ignored. When -p is supplied without name arguments, it
4245 will display the attributes and values of all variables having
4246 the attributes specified by the additional options. If no other
4247 options are supplied with -p, declare will display the
4248 attributes and values of all shell variables. The -f option
4249 will restrict the display to shell functions. The -F option
4250 inhibits the display of function definitions; only the function
4251 name and attributes are printed. If the extdebug shell option
4252 is enabled using shopt, the source file name and line number
4253 where the function is defined are displayed as well. The -F
4254 option implies -f. The -g option forces variables to be created
4255 or modified at the global scope, even when declare is executed
4256 in a shell function. It is ignored in all other cases. The
4257 following options can be used to restrict output to variables
4258 with the specified attribute or to give variables attributes:
4259 -a Each name is an indexed array variable (see Arrays
4260 above).
4261 -A Each name is an associative array variable (see Arrays
4262 above).
4263 -f Use function names only.
4264 -i The variable is treated as an integer; arithmetic evaluaâ€
4265 tion (see ARITHMETIC EVALUATION above) is performed when
4266 the variable is assigned a value.
4267 -l When the variable is assigned a value, all upper-case
4268 characters are converted to lower-case. The upper-case
4269 attribute is disabled.
4270 -n Give each name the nameref attribute, making it a name
4271 reference to another variable. That other variable is
4272 defined by the value of name. All references and assignâ€
4273 ments to name, except for changing the -n attribute
4274 itself, are performed on the variable referenced by
4275 name's value. The -n attribute cannot be applied to
4276 array variables.
4277 -r Make names readonly. These names cannot then be assigned
4278 values by subsequent assignment statements or unset.
4279 -t Give each name the trace attribute. Traced functions
4280 inherit the DEBUG and RETURN traps from the calling
4281 shell. The trace attribute has no special meaning for
4282 variables.
4283 -u When the variable is assigned a value, all lower-case
4284 characters are converted to upper-case. The lower-case
4285 attribute is disabled.
4286 -x Mark names for export to subsequent commands via the
4287 environment.
4288
4289 Using `+' instead of `-' turns off the attribute instead, with
4290 the exceptions that +a may not be used to destroy an array variâ€
4291 able and +r will not remove the readonly attribute. When used
4292 in a function, declare and typeset make each name local, as with
4293 the local command, unless the -g option is supplied. If a variâ€
4294 able name is followed by =value, the value of the variable is
4295 set to value. When using -a or -A and the compound assignment
4296 syntax to create array variables, additional attributes do not
4297 take effect until subsequent assignments. The return value is 0
4298 unless an invalid option is encountered, an attempt is made to
4299 define a function using ``-f foo=bar'', an attempt is made to
4300 assign a value to a readonly variable, an attempt is made to
4301 assign a value to an array variable without using the compound
4302 assignment syntax (see Arrays above), one of the names is not a
4303 valid shell variable name, an attempt is made to turn off readâ€
4304 only status for a readonly variable, an attempt is made to turn
4305 off array status for an array variable, or an attempt is made to
4306 display a non-existent function with -f.
4307
4308 dirs [-clpv] [+n] [-n]
4309 Without options, displays the list of currently remembered
4310 directories. The default display is on a single line with
4311 directory names separated by spaces. Directories are added to
4312 the list with the pushd command; the popd command removes
4313 entries from the list.
4314 -c Clears the directory stack by deleting all of the
4315 entries.
4316 -l Produces a listing using full pathnames; the default
4317 listing format uses a tilde to denote the home directory.
4318 -p Print the directory stack with one entry per line.
4319 -v Print the directory stack with one entry per line, preâ€
4320 fixing each entry with its index in the stack.
4321 +n Displays the nth entry counting from the left of the list
4322 shown by dirs when invoked without options, starting with
4323 zero.
4324 -n Displays the nth entry counting from the right of the
4325 list shown by dirs when invoked without options, starting
4326 with zero.
4327
4328 The return value is 0 unless an invalid option is supplied or n
4329 indexes beyond the end of the directory stack.
4330
4331 disown [-ar] [-h] [jobspec ...]
4332 Without options, remove each jobspec from the table of active
4333 jobs. If jobspec is not present, and neither the -a nor the -r
4334 option is supplied, the current job is used. If the -h option
4335 is given, each jobspec is not removed from the table, but is
4336 marked so that SIGHUP is not sent to the job if the shell
4337 receives a SIGHUP. If no jobspec is supplied, the -a option
4338 means to remove or mark all jobs; the -r option without a jobâ€
4339 spec argument restricts operation to running jobs. The return
4340 value is 0 unless a jobspec does not specify a valid job.
4341
4342 echo [-neE] [arg ...]
4343 Output the args, separated by spaces, followed by a newline.
4344 The return status is 0 unless a write error occurs. If -n is
4345 specified, the trailing newline is suppressed. If the -e option
4346 is given, interpretation of the following backslash-escaped
4347 characters is enabled. The -E option disables the interpretaâ€
4348 tion of these escape characters, even on systems where they are
4349 interpreted by default. The xpg_echo shell option may be used
4350 to dynamically determine whether or not echo expands these
4351 escape characters by default. echo does not interpret -- to
4352 mean the end of options. echo interprets the following escape
4353 sequences:
4354 \a alert (bell)
4355 \b backspace
4356 \c suppress further output
4357 \e
4358 \E an escape character
4359 \f form feed
4360 \n new line
4361 \r carriage return
4362 \t horizontal tab
4363 \v vertical tab
4364 \\ backslash
4365 \0nnn the eight-bit character whose value is the octal value
4366 nnn (zero to three octal digits)
4367 \xHH the eight-bit character whose value is the hexadecimal
4368 value HH (one or two hex digits)
4369 \uHHHH the Unicode (ISO/IEC 10646) character whose value is the
4370 hexadecimal value HHHH (one to four hex digits)
4371 \UHHHHHHHH
4372 the Unicode (ISO/IEC 10646) character whose value is the
4373 hexadecimal value HHHHHHHH (one to eight hex digits)
4374
4375 enable [-a] [-dnps] [-f filename] [name ...]
4376 Enable and disable builtin shell commands. Disabling a builtin
4377 allows a disk command which has the same name as a shell builtin
4378 to be executed without specifying a full pathname, even though
4379 the shell normally searches for builtins before disk commands.
4380 If -n is used, each name is disabled; otherwise, names are
4381 enabled. For example, to use the test binary found via the PATH
4382 instead of the shell builtin version, run ``enable -n test''.
4383 The -f option means to load the new builtin command name from
4384 shared object filename, on systems that support dynamic loading.
4385 The -d option will delete a builtin previously loaded with -f.
4386 If no name arguments are given, or if the -p option is supplied,
4387 a list of shell builtins is printed. With no other option arguâ€
4388 ments, the list consists of all enabled shell builtins. If -n
4389 is supplied, only disabled builtins are printed. If -a is supâ€
4390 plied, the list printed includes all builtins, with an indicaâ€
4391 tion of whether or not each is enabled. If -s is supplied, the
4392 output is restricted to the POSIX special builtins. The return
4393 value is 0 unless a name is not a shell builtin or there is an
4394 error loading a new builtin from a shared object.
4395
4396 eval [arg ...]
4397 The args are read and concatenated together into a single comâ€
4398 mand. This command is then read and executed by the shell, and
4399 its exit status is returned as the value of eval. If there are
4400 no args, or only null arguments, eval returns 0.
4401
4402 exec [-cl] [-a name] [command [arguments]]
4403 If command is specified, it replaces the shell. No new process
4404 is created. The arguments become the arguments to command. If
4405 the -l option is supplied, the shell places a dash at the beginâ€
4406 ning of the zeroth argument passed to command. This is what
4407 login(1) does. The -c option causes command to be executed with
4408 an empty environment. If -a is supplied, the shell passes name
4409 as the zeroth argument to the executed command. If command canâ€
4410 not be executed for some reason, a non-interactive shell exits,
4411 unless the execfail shell option is enabled. In that case, it
4412 returns failure. An interactive shell returns failure if the
4413 file cannot be executed. If command is not specified, any rediâ€
4414 rections take effect in the current shell, and the return status
4415 is 0. If there is a redirection error, the return status is 1.
4416
4417 exit [n]
4418 Cause the shell to exit with a status of n. If n is omitted,
4419 the exit status is that of the last command executed. A trap on
4420 EXIT is executed before the shell terminates.
4421
4422 export [-fn] [name[=word]] ...
4423 export -p
4424 The supplied names are marked for automatic export to the enviâ€
4425 ronment of subsequently executed commands. If the -f option is
4426 given, the names refer to functions. If no names are given, or
4427 if the -p option is supplied, a list of names of all exported
4428 variables is printed. The -n option causes the export property
4429 to be removed from each name. If a variable name is followed by
4430 =word, the value of the variable is set to word. export returns
4431 an exit status of 0 unless an invalid option is encountered, one
4432 of the names is not a valid shell variable name, or -f is supâ€
4433 plied with a name that is not a function.
4434
4435 fc [-e ename] [-lnr] [first] [last]
4436 fc -s [pat=rep] [cmd]
4437 The first form selects a range of commands from first to last
4438 from the history list and displays or edits and re-executes
4439 them. First and last may be specified as a string (to locate
4440 the last command beginning with that string) or as a number (an
4441 index into the history list, where a negative number is used as
4442 an offset from the current command number). If last is not
4443 specified it is set to the current command for listing (so that
4444 ``fc -l -10'' prints the last 10 commands) and to first otherâ€
4445 wise. If first is not specified it is set to the previous comâ€
4446 mand for editing and -16 for listing.
4447
4448 The -n option suppresses the command numbers when listing. The
4449 -r option reverses the order of the commands. If the -l option
4450 is given, the commands are listed on standard output. Otherâ€
4451 wise, the editor given by ename is invoked on a file containing
4452 those commands. If ename is not given, the value of the FCEDIT
4453 variable is used, and the value of EDITOR if FCEDIT is not set.
4454 If neither variable is set, vi is used. When editing is comâ€
4455 plete, the edited commands are echoed and executed.
4456
4457 In the second form, command is re-executed after each instance
4458 of pat is replaced by rep. Command is intepreted the same as
4459 first above. A useful alias to use with this is ``r="fc -s"'',
4460 so that typing ``r cc'' runs the last command beginning with
4461 ``cc'' and typing ``r'' re-executes the last command.
4462
4463 If the first form is used, the return value is 0 unless an
4464 invalid option is encountered or first or last specify history
4465 lines out of range. If the -e option is supplied, the return
4466 value is the value of the last command executed or failure if an
4467 error occurs with the temporary file of commands. If the second
4468 form is used, the return status is that of the command re-exeâ€
4469 cuted, unless cmd does not specify a valid history line, in
4470 which case fc returns failure.
4471
4472 fg [jobspec]
4473 Resume jobspec in the foreground, and make it the current job.
4474 If jobspec is not present, the shell's notion of the current job
4475 is used. The return value is that of the command placed into
4476 the foreground, or failure if run when job control is disabled
4477 or, when run with job control enabled, if jobspec does not specâ€
4478 ify a valid job or jobspec specifies a job that was started
4479 without job control.
4480
4481 getopts optstring name [args]
4482 getopts is used by shell procedures to parse positional parameâ€
4483 ters. optstring contains the option characters to be recogâ€
4484 nized; if a character is followed by a colon, the option is
4485 expected to have an argument, which should be separated from it
4486 by white space. The colon and question mark characters may not
4487 be used as option characters. Each time it is invoked, getopts
4488 places the next option in the shell variable name, initializing
4489 name if it does not exist, and the index of the next argument to
4490 be processed into the variable OPTIND. OPTIND is initialized to
4491 1 each time the shell or a shell script is invoked. When an
4492 option requires an argument, getopts places that argument into
4493 the variable OPTARG. The shell does not reset OPTIND automatiâ€
4494 cally; it must be manually reset between multiple calls to
4495 getopts within the same shell invocation if a new set of parameâ€
4496 ters is to be used.
4497
4498 When the end of options is encountered, getopts exits with a
4499 return value greater than zero. OPTIND is set to the index of
4500 the first non-option argument, and name is set to ?.
4501
4502 getopts normally parses the positional parameters, but if more
4503 arguments are given in args, getopts parses those instead.
4504
4505 getopts can report errors in two ways. If the first character
4506 of optstring is a colon, silent error reporting is used. In
4507 normal operation, diagnostic messages are printed when invalid
4508 options or missing option arguments are encountered. If the
4509 variable OPTERR is set to 0, no error messages will be disâ€
4510 played, even if the first character of optstring is not a colon.
4511
4512 If an invalid option is seen, getopts places ? into name and, if
4513 not silent, prints an error message and unsets OPTARG. If
4514 getopts is silent, the option character found is placed in
4515 OPTARG and no diagnostic message is printed.
4516
4517 If a required argument is not found, and getopts is not silent,
4518 a question mark (?) is placed in name, OPTARG is unset, and a
4519 diagnostic message is printed. If getopts is silent, then a
4520 colon (:) is placed in name and OPTARG is set to the option
4521 character found.
4522
4523 getopts returns true if an option, specified or unspecified, is
4524 found. It returns false if the end of options is encountered or
4525 an error occurs.
4526
4527 hash [-lr] [-p filename] [-dt] [name]
4528 Each time hash is invoked, the full pathname of the command name
4529 is determined by searching the directories in $PATH and rememâ€
4530 bered. Any previously-remembered pathname is discarded. If the
4531 -p option is supplied, no path search is performed, and filename
4532 is used as the full filename of the command. The -r option
4533 causes the shell to forget all remembered locations. The -d
4534 option causes the shell to forget the remembered location of
4535 each name. If the -t option is supplied, the full pathname to
4536 which each name corresponds is printed. If multiple name arguâ€
4537 ments are supplied with -t, the name is printed before the
4538 hashed full pathname. The -l option causes output to be disâ€
4539 played in a format that may be reused as input. If no arguments
4540 are given, or if only -l is supplied, information about rememâ€
4541 bered commands is printed. The return status is true unless a
4542 name is not found or an invalid option is supplied.
4543
4544 help [-dms] [pattern]
4545 Display helpful information about builtin commands. If pattern
4546 is specified, help gives detailed help on all commands matching
4547 pattern; otherwise help for all the builtins and shell control
4548 structures is printed.
4549 -d Display a short description of each pattern
4550 -m Display the description of each pattern in a manpage-like
4551 format
4552 -s Display only a short usage synopsis for each pattern
4553
4554 The return status is 0 unless no command matches pattern.
4555
4556 history [n]
4557 history -c
4558 history -d offset
4559 history -anrw [filename]
4560 history -p arg [arg ...]
4561 history -s arg [arg ...]
4562 With no options, display the command history list with line numâ€
4563 bers. Lines listed with a * have been modified. An argument of
4564 n lists only the last n lines. If the shell variable HISTTIMEâ€
4565 FORMAT is set and not null, it is used as a format string for
4566 strftime(3) to display the time stamp associated with each disâ€
4567 played history entry. No intervening blank is printed between
4568 the formatted time stamp and the history line. If filename is
4569 supplied, it is used as the name of the history file; if not,
4570 the value of HISTFILE is used. Options, if supplied, have the
4571 following meanings:
4572 -c Clear the history list by deleting all the entries.
4573 -d offset
4574 Delete the history entry at position offset.
4575 -a Append the ``new'' history lines (history lines entered
4576 since the beginning of the current bash session) to the
4577 history file.
4578 -n Read the history lines not already read from the history
4579 file into the current history list. These are lines
4580 appended to the history file since the beginning of the
4581 current bash session.
4582 -r Read the contents of the history file and append them to
4583 the current history list.
4584 -w Write the current history list to the history file, overâ€
4585 writing the history file's contents.
4586 -p Perform history substitution on the following args and
4587 display the result on the standard output. Does not
4588 store the results in the history list. Each arg must be
4589 quoted to disable normal history expansion.
4590 -s Store the args in the history list as a single entry.
4591 The last command in the history list is removed before
4592 the args are added.
4593
4594 If the HISTTIMEFORMAT variable is set, the time stamp informaâ€
4595 tion associated with each history entry is written to the hisâ€
4596 tory file, marked with the history comment character. When the
4597 history file is read, lines beginning with the history comment
4598 character followed immediately by a digit are interpreted as
4599 timestamps for the previous history line. The return value is 0
4600 unless an invalid option is encountered, an error occurs while
4601 reading or writing the history file, an invalid offset is supâ€
4602 plied as an argument to -d, or the history expansion supplied as
4603 an argument to -p fails.
4604
4605 jobs [-lnprs] [ jobspec ... ]
4606 jobs -x command [ args ... ]
4607 The first form lists the active jobs. The options have the folâ€
4608 lowing meanings:
4609 -l List process IDs in addition to the normal information.
4610 -n Display information only about jobs that have changed
4611 status since the user was last notified of their status.
4612 -p List only the process ID of the job's process group
4613 leader.
4614 -r Display only running jobs.
4615 -s Display only stopped jobs.
4616
4617 If jobspec is given, output is restricted to information about
4618 that job. The return status is 0 unless an invalid option is
4619 encountered or an invalid jobspec is supplied.
4620
4621 If the -x option is supplied, jobs replaces any jobspec found in
4622 command or args with the corresponding process group ID, and
4623 executes command passing it args, returning its exit status.
4624
4625 kill [-s sigspec | -n signum | -sigspec] [pid | jobspec] ...
4626 kill -l [sigspec | exit_status]
4627 Send the signal named by sigspec or signum to the processes
4628 named by pid or jobspec. sigspec is either a case-insensitive
4629 signal name such as SIGKILL (with or without the SIG prefix) or
4630 a signal number; signum is a signal number. If sigspec is not
4631 present, then SIGTERM is assumed. An argument of -l lists the
4632 signal names. If any arguments are supplied when -l is given,
4633 the names of the signals corresponding to the arguments are
4634 listed, and the return status is 0. The exit_status argument to
4635 -l is a number specifying either a signal number or the exit
4636 status of a process terminated by a signal. kill returns true
4637 if at least one signal was successfully sent, or false if an
4638 error occurs or an invalid option is encountered.
4639
4640 let arg [arg ...]
4641 Each arg is an arithmetic expression to be evaluated (see ARITHâ€
4642 METIC EVALUATION above). If the last arg evaluates to 0, let
4643 returns 1; 0 is returned otherwise.
4644
4645 local [option] [name[=value] ...]
4646 For each argument, a local variable named name is created, and
4647 assigned value. The option can be any of the options accepted
4648 by declare. When local is used within a function, it causes the
4649 variable name to have a visible scope restricted to that funcâ€
4650 tion and its children. With no operands, local writes a list of
4651 local variables to the standard output. It is an error to use
4652 local when not within a function. The return status is 0 unless
4653 local is used outside a function, an invalid name is supplied,
4654 or name is a readonly variable.
4655
4656 logout Exit a login shell.
4657
4658 mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback]
4659 [-c quantum] [array]
4660 readarray [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback]
4661 [-c quantum] [array]
4662 Read lines from the standard input into the indexed array variâ€
4663 able array, or from file descriptor fd if the -u option is supâ€
4664 plied. The variable MAPFILE is the default array. Options, if
4665 supplied, have the following meanings:
4666 -n Copy at most count lines. If count is 0, all lines are
4667 copied.
4668 -O Begin assigning to array at index origin. The default
4669 index is 0.
4670 -s Discard the first count lines read.
4671 -t Remove a trailing newline from each line read.
4672 -u Read lines from file descriptor fd instead of the stanâ€
4673 dard input.
4674 -C Evaluate callback each time quantum lines are read. The
4675 -c option specifies quantum.
4676 -c Specify the number of lines read between each call to
4677 callback.
4678
4679 If -C is specified without -c, the default quantum is 5000.
4680 When callback is evaluated, it is supplied the index of the next
4681 array element to be assigned and the line to be assigned to that
4682 element as additional arguments. callback is evaluated after
4683 the line is read but before the array element is assigned.
4684
4685 If not supplied with an explicit origin, mapfile will clear
4686 array before assigning to it.
4687
4688 mapfile returns successfully unless an invalid option or option
4689 argument is supplied, array is invalid or unassignable, or if
4690 array is not an indexed array.
4691
4692 popd [-n] [+n] [-n]
4693 Removes entries from the directory stack. With no arguments,
4694 removes the top directory from the stack, and performs a cd to
4695 the new top directory. Arguments, if supplied, have the followâ€
4696 ing meanings:
4697 -n Suppresses the normal change of directory when removing
4698 directories from the stack, so that only the stack is
4699 manipulated.
4700 +n Removes the nth entry counting from the left of the list
4701 shown by dirs, starting with zero. For example: ``popd
4702 +0'' removes the first directory, ``popd +1'' the second.
4703 -n Removes the nth entry counting from the right of the list
4704 shown by dirs, starting with zero. For example: ``popd
4705 -0'' removes the last directory, ``popd -1'' the next to
4706 last.
4707
4708 If the popd command is successful, a dirs is performed as well,
4709 and the return status is 0. popd returns false if an invalid
4710 option is encountered, the directory stack is empty, a non-exisâ€
4711 tent directory stack entry is specified, or the directory change
4712 fails.
4713
4714 printf [-v var] format [arguments]
4715 Write the formatted arguments to the standard output under the
4716 control of the format. The -v option causes the output to be
4717 assigned to the variable var rather than being printed to the
4718 standard output.
4719
4720 The format is a character string which contains three types of
4721 objects: plain characters, which are simply copied to standard
4722 output, character escape sequences, which are converted and
4723 copied to the standard output, and format specifications, each
4724 of which causes printing of the next successive argument. In
4725 addition to the standard printf(1) format specifications, printf
4726 interprets the following extensions:
4727 %b causes printf to expand backslash escape sequences in the
4728 corresponding argument (except that \c terminates output,
4729 backslashes in \', \", and \? are not removed, and octal
4730 escapes beginning with \0 may contain up to four digits).
4731 %q causes printf to output the corresponding argument in a
4732 format that can be reused as shell input.
4733 %(datefmt)T
4734 causes printf to output the date-time string resulting
4735 from using datefmt as a format string for strftime(3).
4736 The corresponding argument is an integer representing the
4737 number of seconds since the epoch. Two special argument
4738 values may be used: -1 represents the current time, and
4739 -2 represents the time the shell was invoked. If no
4740 argument is specified, conversion behaves as if -1 had
4741 been given. This is an exception to the usual printf
4742 behavior.
4743
4744 Arguments to non-string format specifiers are treated as C conâ€
4745 stants, except that a leading plus or minus sign is allowed, and
4746 if the leading character is a single or double quote, the value
4747 is the ASCII value of the following character.
4748
4749 The format is reused as necessary to consume all of the arguâ€
4750 ments. If the format requires more arguments than are supplied,
4751 the extra format specifications behave as if a zero value or
4752 null string, as appropriate, had been supplied. The return
4753 value is zero on success, non-zero on failure.
4754
4755 pushd [-n] [+n] [-n]
4756 pushd [-n] [dir]
4757 Adds a directory to the top of the directory stack, or rotates
4758 the stack, making the new top of the stack the current working
4759 directory. With no arguments, exchanges the top two directories
4760 and returns 0, unless the directory stack is empty. Arguments,
4761 if supplied, have the following meanings:
4762 -n Suppresses the normal change of directory when adding
4763 directories to the stack, so that only the stack is
4764 manipulated.
4765 +n Rotates the stack so that the nth directory (counting
4766 from the left of the list shown by dirs, starting with
4767 zero) is at the top.
4768 -n Rotates the stack so that the nth directory (counting
4769 from the right of the list shown by dirs, starting with
4770 zero) is at the top.
4771 dir Adds dir to the directory stack at the top, making it the
4772 new current working directory as if it had been supplied
4773 as the argument to the cd builtin.
4774
4775 If the pushd command is successful, a dirs is performed as well.
4776 If the first form is used, pushd returns 0 unless the cd to dir
4777 fails. With the second form, pushd returns 0 unless the direcâ€
4778 tory stack is empty, a non-existent directory stack element is
4779 specified, or the directory change to the specified new current
4780 directory fails.
4781
4782 pwd [-LP]
4783 Print the absolute pathname of the current working directory.
4784 The pathname printed contains no symbolic links if the -P option
4785 is supplied or the -o physical option to the set builtin command
4786 is enabled. If the -L option is used, the pathname printed may
4787 contain symbolic links. The return status is 0 unless an error
4788 occurs while reading the name of the current directory or an
4789 invalid option is supplied.
4790
4791 read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p
4792 prompt] [-t timeout] [-u fd] [name ...]
4793 One line is read from the standard input, or from the file
4794 descriptor fd supplied as an argument to the -u option, and the
4795 first word is assigned to the first name, the second word to the
4796 second name, and so on, with leftover words and their intervenâ€
4797 ing separators assigned to the last name. If there are fewer
4798 words read from the input stream than names, the remaining names
4799 are assigned empty values. The characters in IFS are used to
4800 split the line into words using the same rules the shell uses
4801 for expansion (described above under Word Splitting). The backâ€
4802 slash character (\) may be used to remove any special meaning
4803 for the next character read and for line continuation. Options,
4804 if supplied, have the following meanings:
4805 -a aname
4806 The words are assigned to sequential indices of the array
4807 variable aname, starting at 0. aname is unset before any
4808 new values are assigned. Other name arguments are
4809 ignored.
4810 -d delim
4811 The first character of delim is used to terminate the
4812 input line, rather than newline.
4813 -e If the standard input is coming from a terminal, readline
4814 (see READLINE above) is used to obtain the line. Readâ€
4815 line uses the current (or default, if line editing was
4816 not previously active) editing settings.
4817 -i text
4818 If readline is being used to read the line, text is
4819 placed into the editing buffer before editing begins.
4820 -n nchars
4821 read returns after reading nchars characters rather than
4822 waiting for a complete line of input, but honor a delimâ€
4823 iter if fewer than nchars characters are read before the
4824 delimiter.
4825 -N nchars
4826 read returns after reading exactly nchars characters
4827 rather than waiting for a complete line of input, unless
4828 EOF is encountered or read times out. Delimiter characâ€
4829 ters encountered in the input are not treated specially
4830 and do not cause read to return until nchars characters
4831 are read.
4832 -p prompt
4833 Display prompt on standard error, without a trailing newâ€
4834 line, before attempting to read any input. The prompt is
4835 displayed only if input is coming from a terminal.
4836 -r Backslash does not act as an escape character. The backâ€
4837 slash is considered to be part of the line. In particuâ€
4838 lar, a backslash-newline pair may not be used as a line
4839 continuation.
4840 -s Silent mode. If input is coming from a terminal, characâ€
4841 ters are not echoed.
4842 -t timeout
4843 Cause read to time out and return failure if a complete
4844 line of input (or a specified number of characters) is
4845 not read within timeout seconds. timeout may be a deciâ€
4846 mal number with a fractional portion following the deciâ€
4847 mal point. This option is only effective if read is
4848 reading input from a terminal, pipe, or other special
4849 file; it has no effect when reading from regular files.
4850 If read times out, read saves any partial input read into
4851 the specified variable name. If timeout is 0, read
4852 returns immediately, without trying to read any data.
4853 The exit status is 0 if input is available on the speciâ€
4854 fied file descriptor, non-zero otherwise. The exit staâ€
4855 tus is greater than 128 if the timeout is exceeded.
4856 -u fd Read input from file descriptor fd.
4857
4858 If no names are supplied, the line read is assigned to the variâ€
4859 able REPLY. The return code is zero, unless end-of-file is
4860 encountered, read times out (in which case the return code is
4861 greater than 128), a variable assignment error (such as assignâ€
4862 ing to a readonly variable) occurs, or an invalid file descripâ€
4863 tor is supplied as the argument to -u.
4864
4865 readonly [-aAf] [-p] [name[=word] ...]
4866 The given names are marked readonly; the values of these names
4867 may not be changed by subsequent assignment. If the -f option
4868 is supplied, the functions corresponding to the names are so
4869 marked. The -a option restricts the variables to indexed
4870 arrays; the -A option restricts the variables to associative
4871 arrays. If both options are supplied, -A takes precedence. If
4872 no name arguments are given, or if the -p option is supplied, a
4873 list of all readonly names is printed. The other options may be
4874 used to restrict the output to a subset of the set of readonly
4875 names. The -p option causes output to be displayed in a format
4876 that may be reused as input. If a variable name is followed by
4877 =word, the value of the variable is set to word. The return
4878 status is 0 unless an invalid option is encountered, one of the
4879 names is not a valid shell variable name, or -f is supplied with
4880 a name that is not a function.
4881
4882 return [n]
4883 Causes a function to stop executing and return the value speciâ€
4884 fied by n to its caller. If n is omitted, the return status is
4885 that of the last command executed in the function body. If
4886 return is used outside a function, but during execution of a
4887 script by the . (source) command, it causes the shell to stop
4888 executing that script and return either n or the exit status of
4889 the last command executed within the script as the exit status
4890 of the script. If n is supplied, the return value is its least
4891 significant 8 bits. The return status is non-zero if return is
4892 supplied a non-numeric argument, or is used outside a function
4893 and not during execution of a script by . or source. Any comâ€
4894 mand associated with the RETURN trap is executed before execuâ€
4895 tion resumes after the function or script.
4896
4897 set [--abefhkmnptuvxBCEHPT] [-o option-name] [arg ...]
4898 set [+abefhkmnptuvxBCEHPT] [+o option-name] [arg ...]
4899 Without options, the name and value of each shell variable are
4900 displayed in a format that can be reused as input for setting or
4901 resetting the currently-set variables. Read-only variables canâ€
4902 not be reset. In posix mode, only shell variables are listed.
4903 The output is sorted according to the current locale. When
4904 options are specified, they set or unset shell attributes. Any
4905 arguments remaining after option processing are treated as valâ€
4906 ues for the positional parameters and are assigned, in order, to
4907 $1, $2, ... $n. Options, if specified, have the following
4908 meanings:
4909 -a Automatically mark variables and functions which are
4910 modified or created for export to the environment of
4911 subsequent commands.
4912 -b Report the status of terminated background jobs immediâ€
4913 ately, rather than before the next primary prompt. This
4914 is effective only when job control is enabled.
4915 -e Exit immediately if a pipeline (which may consist of a
4916 single simple command), a list, or a compound command
4917 (see SHELL GRAMMAR above), exits with a non-zero staâ€
4918 tus. The shell does not exit if the command that fails
4919 is part of the command list immediately following a
4920 while or until keyword, part of the test following the
4921 if or elif reserved words, part of any command executed
4922 in a && or || list except the command following the
4923 final && or ||, any command in a pipeline but the last,
4924 or if the command's return value is being inverted with
4925 !. If a compound command other than a subshell returns
4926 a non-zero status because a command failed while -e was
4927 being ignored, the shell does not exit. A trap on ERR,
4928 if set, is executed before the shell exits. This option
4929 applies to the shell environment and each subshell enviâ€
4930 ronment separately (see COMMAND EXECUTION ENVIRONMENT
4931 above), and may cause subshells to exit before executing
4932 all the commands in the subshell.
4933
4934 If a compound command or shell function executes in a
4935 context where -e is being ignored, none of the commands
4936 executed within the compound command or function body
4937 will be affected by the -e setting, even if -e is set
4938 and a command returns a failure status. If a compound
4939 command or shell function sets -e while executing in a
4940 context where -e is ignored, that setting will not have
4941 any effect until the compound command or the command
4942 containing the function call completes.
4943 -f Disable pathname expansion.
4944 -h Remember the location of commands as they are looked up
4945 for execution. This is enabled by default.
4946 -k All arguments in the form of assignment statements are
4947 placed in the environment for a command, not just those
4948 that precede the command name.
4949 -m Monitor mode. Job control is enabled. This option is
4950 on by default for interactive shells on systems that
4951 support it (see JOB CONTROL above). All processes run
4952 in a separate process group. When a background job comâ€
4953 pletes, the shell prints a line containing its exit staâ€
4954 tus.
4955 -n Read commands but do not execute them. This may be used
4956 to check a shell script for syntax errors. This is
4957 ignored by interactive shells.
4958 -o option-name
4959 The option-name can be one of the following:
4960 allexport
4961 Same as -a.
4962 braceexpand
4963 Same as -B.
4964 emacs Use an emacs-style command line editing interâ€
4965 face. This is enabled by default when the shell
4966 is interactive, unless the shell is started with
4967 the --noediting option. This also affects the
4968 editing interface used for read -e.
4969 errexit Same as -e.
4970 errtrace
4971 Same as -E.
4972 functrace
4973 Same as -T.
4974 hashall Same as -h.
4975 histexpand
4976 Same as -H.
4977 history Enable command history, as described above under
4978 HISTORY. This option is on by default in interâ€
4979 active shells.
4980 ignoreeof
4981 The effect is as if the shell command
4982 ``IGNOREEOF=10'' had been executed (see Shell
4983 Variables above).
4984 keyword Same as -k.
4985 monitor Same as -m.
4986 noclobber
4987 Same as -C.
4988 noexec Same as -n.
4989 noglob Same as -f.
4990 nolog Currently ignored.
4991 notify Same as -b.
4992 nounset Same as -u.
4993 onecmd Same as -t.
4994 physical
4995 Same as -P.
4996 pipefail
4997 If set, the return value of a pipeline is the
4998 value of the last (rightmost) command to exit
4999 with a non-zero status, or zero if all commands
5000 in the pipeline exit successfully. This option
5001 is disabled by default.
5002 posix Change the behavior of bash where the default
5003 operation differs from the POSIX standard to
5004 match the standard (posix mode). See SEE ALSO
5005 below for a reference to a document that details
5006 how posix mode affects bash's behavior.
5007 privileged
5008 Same as -p.
5009 verbose Same as -v.
5010 vi Use a vi-style command line editing interface.
5011 This also affects the editing interface used for
5012 read -e.
5013 xtrace Same as -x.
5014 If -o is supplied with no option-name, the values of the
5015 current options are printed. If +o is supplied with no
5016 option-name, a series of set commands to recreate the
5017 current option settings is displayed on the standard
5018 output.
5019 -p Turn on privileged mode. In this mode, the $ENV and
5020 $BASH_ENV files are not processed, shell functions are
5021 not inherited from the environment, and the SHELLOPTS,
5022 BASHOPTS, CDPATH, and GLOBIGNORE variables, if they
5023 appear in the environment, are ignored. If the shell is
5024 started with the effective user (group) id not equal to
5025 the real user (group) id, and the -p option is not supâ€
5026 plied, these actions are taken and the effective user id
5027 is set to the real user id. If the -p option is supâ€
5028 plied at startup, the effective user id is not reset.
5029 Turning this option off causes the effective user and
5030 group ids to be set to the real user and group ids.
5031 -t Exit after reading and executing one command.
5032 -u Treat unset variables and parameters other than the speâ€
5033 cial parameters "@" and "*" as an error when performing
5034 parameter expansion. If expansion is attempted on an
5035 unset variable or parameter, the shell prints an error
5036 message, and, if not interactive, exits with a non-zero
5037 status.
5038 -v Print shell input lines as they are read.
5039 -x After expanding each simple command, for command, case
5040 command, select command, or arithmetic for command, disâ€
5041 play the expanded value of PS4, followed by the command
5042 and its expanded arguments or associated word list.
5043 -B The shell performs brace expansion (see Brace Expansion
5044 above). This is on by default.
5045 -C If set, bash does not overwrite an existing file with
5046 the >, >&, and <> redirection operators. This may be
5047 overridden when creating output files by using the rediâ€
5048 rection operator >| instead of >.
5049 -E If set, any trap on ERR is inherited by shell functions,
5050 command substitutions, and commands executed in a subâ€
5051 shell environment. The ERR trap is normally not inherâ€
5052 ited in such cases.
5053 -H Enable ! style history substitution. This option is on
5054 by default when the shell is interactive.
5055 -P If set, the shell does not resolve symbolic links when
5056 executing commands such as cd that change the current
5057 working directory. It uses the physical directory
5058 structure instead. By default, bash follows the logical
5059 chain of directories when performing commands which
5060 change the current directory.
5061 -T If set, any traps on DEBUG and RETURN are inherited by
5062 shell functions, command substitutions, and commands
5063 executed in a subshell environment. The DEBUG and
5064 RETURN traps are normally not inherited in such cases.
5065 -- If no arguments follow this option, then the positional
5066 parameters are unset. Otherwise, the positional parameâ€
5067 ters are set to the args, even if some of them begin
5068 with a -.
5069 - Signal the end of options, cause all remaining args to
5070 be assigned to the positional parameters. The -x and -v
5071 options are turned off. If there are no args, the posiâ€
5072 tional parameters remain unchanged.
5073
5074 The options are off by default unless otherwise noted. Using +
5075 rather than - causes these options to be turned off. The
5076 options can also be specified as arguments to an invocation of
5077 the shell. The current set of options may be found in $-. The
5078 return status is always true unless an invalid option is encounâ€
5079 tered.
5080
5081 shift [n]
5082 The positional parameters from n+1 ... are renamed to $1 ....
5083 Parameters represented by the numbers $# down to $#-n+1 are
5084 unset. n must be a non-negative number less than or equal to
5085 $#. If n is 0, no parameters are changed. If n is not given,
5086 it is assumed to be 1. If n is greater than $#, the positional
5087 parameters are not changed. The return status is greater than
5088 zero if n is greater than $# or less than zero; otherwise 0.
5089
5090 shopt [-pqsu] [-o] [optname ...]
5091 Toggle the values of settings controlling optional shell behavâ€
5092 ior. The settings can be either those listed below, or, if the
5093 -o option is used, those available with the -o option to the set
5094 builtin command. With no options, or with the -p option, a list
5095 of all settable options is displayed, with an indication of
5096 whether or not each is set. The -p option causes output to be
5097 displayed in a form that may be reused as input. Other options
5098 have the following meanings:
5099 -s Enable (set) each optname.
5100 -u Disable (unset) each optname.
5101 -q Suppresses normal output (quiet mode); the return status
5102 indicates whether the optname is set or unset. If multiâ€
5103 ple optname arguments are given with -q, the return staâ€
5104 tus is zero if all optnames are enabled; non-zero otherâ€
5105 wise.
5106 -o Restricts the values of optname to be those defined for
5107 the -o option to the set builtin.
5108
5109 If either -s or -u is used with no optname arguments, shopt
5110 shows only those options which are set or unset, respectively.
5111 Unless otherwise noted, the shopt options are disabled (unset)
5112 by default.
5113
5114 The return status when listing options is zero if all optnames
5115 are enabled, non-zero otherwise. When setting or unsetting
5116 options, the return status is zero unless an optname is not a
5117 valid shell option.
5118
5119 The list of shopt options is:
5120
5121 autocd If set, a command name that is the name of a directory
5122 is executed as if it were the argument to the cd comâ€
5123 mand. This option is only used by interactive shells.
5124 cdable_vars
5125 If set, an argument to the cd builtin command that is
5126 not a directory is assumed to be the name of a variable
5127 whose value is the directory to change to.
5128 cdspell If set, minor errors in the spelling of a directory comâ€
5129 ponent in a cd command will be corrected. The errors
5130 checked for are transposed characters, a missing characâ€
5131 ter, and one character too many. If a correction is
5132 found, the corrected filename is printed, and the comâ€
5133 mand proceeds. This option is only used by interactive
5134 shells.
5135 checkhash
5136 If set, bash checks that a command found in the hash taâ€
5137 ble exists before trying to execute it. If a hashed
5138 command no longer exists, a normal path search is perâ€
5139 formed.
5140 checkjobs
5141 If set, bash lists the status of any stopped and running
5142 jobs before exiting an interactive shell. If any jobs
5143 are running, this causes the exit to be deferred until a
5144 second exit is attempted without an intervening command
5145 (see JOB CONTROL above). The shell always postpones
5146 exiting if any jobs are stopped.
5147 checkwinsize
5148 If set, bash checks the window size after each command
5149 and, if necessary, updates the values of LINES and COLâ€
5150 UMNS.
5151 cmdhist If set, bash attempts to save all lines of a multiple-
5152 line command in the same history entry. This allows
5153 easy re-editing of multi-line commands.
5154 compat31
5155 If set, bash changes its behavior to that of version 3.1
5156 with respect to quoted arguments to the [[ conditional
5157 command's =~ operator and locale-specific string comparâ€
5158 ison when using the [[ conditional command's < and >
5159 operators. Bash versions prior to bash-4.1 use ASCII
5160 collation and strcmp(3); bash-4.1 and later use the curâ€
5161 rent locale's collation sequence and strcoll(3).
5162 compat32
5163 If set, bash changes its behavior to that of version 3.2
5164 with respect to locale-specific string comparison when
5165 using the [[ conditional command's < and > operators
5166 (see previous item).
5167 compat40
5168 If set, bash changes its behavior to that of version 4.0
5169 with respect to locale-specific string comparison when
5170 using the [[ conditional command's < and > operators
5171 (see description of compat31) and the effect of interâ€
5172 rupting a command list. Bash versions 4.0 and later
5173 interrupt the list as if the shell received the interâ€
5174 rupt; previous versions continue with the next command
5175 in the list.
5176 compat41
5177 If set, bash, when in posix mode, treats a single quote
5178 in a double-quoted parameter expansion as a special
5179 character. The single quotes must match (an even numâ€
5180 ber) and the characters between the single quotes are
5181 considered quoted. This is the behavior of posix mode
5182 through version 4.1. The default bash behavior remains
5183 as in previous versions.
5184 compat42
5185 If set, bash does not process the replacement string in
5186 the pattern substitution word expansion using quote
5187 removal.
5188 complete_fullquote
5189 If set, bash quotes all shell metacharacters in fileâ€
5190 names and directory names when performing completion.
5191 If not set, bash removes metacharacters such as the dolâ€
5192 lar sign from the set of characters that will be quoted
5193 in completed filenames when these metacharacters appear
5194 in shell variable references in words to be completed.
5195 This means that dollar signs in variable names that
5196 expand to directories will not be quoted; however, any
5197 dollar signs appearing in filenames will not be quoted,
5198 either. This is active only when bash is using backâ€
5199 slashes to quote completed filenames. This variable is
5200 set by default, which is the default bash behavior in
5201 versions through 4.2.
5202 direxpand
5203 If set, bash replaces directory names with the results
5204 of word expansion when performing filename completion.
5205 This changes the contents of the readline editing bufâ€
5206 fer. If not set, bash attempts to preserve what the
5207 user typed.
5208 dirspell
5209 If set, bash attempts spelling correction on directory
5210 names during word completion if the directory name iniâ€
5211 tially supplied does not exist.
5212 dotglob If set, bash includes filenames beginning with a `.' in
5213 the results of pathname expansion.
5214 execfail
5215 If set, a non-interactive shell will not exit if it canâ€
5216 not execute the file specified as an argument to the
5217 exec builtin command. An interactive shell does not
5218 exit if exec fails.
5219 expand_aliases
5220 If set, aliases are expanded as described above under
5221 ALIASES. This option is enabled by default for interacâ€
5222 tive shells.
5223 extdebug
5224 If set, behavior intended for use by debuggers is
5225 enabled:
5226 1. The -F option to the declare builtin displays the
5227 source file name and line number corresponding to
5228 each function name supplied as an argument.
5229 2. If the command run by the DEBUG trap returns a
5230 non-zero value, the next command is skipped and
5231 not executed.
5232 3. If the command run by the DEBUG trap returns a
5233 value of 2, and the shell is executing in a subâ€
5234 routine (a shell function or a shell script exeâ€
5235 cuted by the . or source builtins), a call to
5236 return is simulated.
5237 4. BASH_ARGC and BASH_ARGV are updated as described
5238 in their descriptions above.
5239 5. Function tracing is enabled: command substituâ€
5240 tion, shell functions, and subshells invoked with
5241 ( command ) inherit the DEBUG and RETURN traps.
5242 6. Error tracing is enabled: command substitution,
5243 shell functions, and subshells invoked with (
5244 command ) inherit the ERR trap.
5245 extglob If set, the extended pattern matching features described
5246 above under Pathname Expansion are enabled.
5247 extquote
5248 If set, $'string' and $"string" quoting is performed
5249 within ${parameter} expansions enclosed in double
5250 quotes. This option is enabled by default.
5251 failglob
5252 If set, patterns which fail to match filenames during
5253 pathname expansion result in an expansion error.
5254 force_fignore
5255 If set, the suffixes specified by the FIGNORE shell
5256 variable cause words to be ignored when performing word
5257 completion even if the ignored words are the only possiâ€
5258 ble completions. See SHELL VARIABLES above for a
5259 description of FIGNORE. This option is enabled by
5260 default.
5261 globasciiranges
5262 If set, range expressions used in pattern matching
5263 bracket expressions (see Pattern Matching above) behave
5264 as if in the traditional C locale when performing comâ€
5265 parisons. That is, the current locale's collating
5266 sequence is not taken into account, so b will not colâ€
5267 late between A and B, and upper-case and lower-case
5268 ASCII characters will collate together.
5269 globstar
5270 If set, the pattern ** used in a pathname expansion conâ€
5271 text will match all files and zero or more directories
5272 and subdirectories. If the pattern is followed by a /,
5273 only directories and subdirectories match.
5274 gnu_errfmt
5275 If set, shell error messages are written in the standard
5276 GNU error message format.
5277 histappend
5278 If set, the history list is appended to the file named
5279 by the value of the HISTFILE variable when the shell
5280 exits, rather than overwriting the file.
5281 histreedit
5282 If set, and readline is being used, a user is given the
5283 opportunity to re-edit a failed history substitution.
5284 histverify
5285 If set, and readline is being used, the results of hisâ€
5286 tory substitution are not immediately passed to the
5287 shell parser. Instead, the resulting line is loaded
5288 into the readline editing buffer, allowing further modiâ€
5289 fication.
5290 hostcomplete
5291 If set, and readline is being used, bash will attempt to
5292 perform hostname completion when a word containing a @
5293 is being completed (see Completing under READLINE
5294 above). This is enabled by default.
5295 huponexit
5296 If set, bash will send SIGHUP to all jobs when an interâ€
5297 active login shell exits.
5298 interactive_comments
5299 If set, allow a word beginning with # to cause that word
5300 and all remaining characters on that line to be ignored
5301 in an interactive shell (see COMMENTS above). This
5302 option is enabled by default.
5303 lastpipe
5304 If set, and job control is not active, the shell runs
5305 the last command of a pipeline not executed in the backâ€
5306 ground in the current shell environment.
5307 lithist If set, and the cmdhist option is enabled, multi-line
5308 commands are saved to the history with embedded newlines
5309 rather than using semicolon separators where possible.
5310 login_shell
5311 The shell sets this option if it is started as a login
5312 shell (see INVOCATION above). The value may not be
5313 changed.
5314 mailwarn
5315 If set, and a file that bash is checking for mail has
5316 been accessed since the last time it was checked, the
5317 message ``The mail in mailfile has been read'' is disâ€
5318 played.
5319 no_empty_cmd_completion
5320 If set, and readline is being used, bash will not
5321 attempt to search the PATH for possible completions when
5322 completion is attempted on an empty line.
5323 nocaseglob
5324 If set, bash matches filenames in a case-insensitive
5325 fashion when performing pathname expansion (see Pathname
5326 Expansion above).
5327 nocasematch
5328 If set, bash matches patterns in a case-insensitive
5329 fashion when performing matching while executing case or
5330 [[ conditional commands.
5331 nullglob
5332 If set, bash allows patterns which match no files (see
5333 Pathname Expansion above) to expand to a null string,
5334 rather than themselves.
5335 progcomp
5336 If set, the programmable completion facilities (see Proâ€
5337 grammable Completion above) are enabled. This option is
5338 enabled by default.
5339 promptvars
5340 If set, prompt strings undergo parameter expansion, comâ€
5341 mand substitution, arithmetic expansion, and quote
5342 removal after being expanded as described in PROMPTING
5343 above. This option is enabled by default.
5344 restricted_shell
5345 The shell sets this option if it is started in
5346 restricted mode (see RESTRICTED SHELL below). The value
5347 may not be changed. This is not reset when the startup
5348 files are executed, allowing the startup files to disâ€
5349 cover whether or not a shell is restricted.
5350 shift_verbose
5351 If set, the shift builtin prints an error message when
5352 the shift count exceeds the number of positional parameâ€
5353 ters.
5354 sourcepath
5355 If set, the source (.) builtin uses the value of PATH to
5356 find the directory containing the file supplied as an
5357 argument. This option is enabled by default.
5358 xpg_echo
5359 If set, the echo builtin expands backslash-escape
5360 sequences by default.
5361
5362 suspend [-f]
5363 Suspend the execution of this shell until it receives a SIGCONT
5364 signal. A login shell cannot be suspended; the -f option can be
5365 used to override this and force the suspension. The return staâ€
5366 tus is 0 unless the shell is a login shell and -f is not supâ€
5367 plied, or if job control is not enabled.
5368
5369 test expr
5370 [ expr ]
5371 Return a status of 0 (true) or 1 (false) depending on the evaluâ€
5372 ation of the conditional expression expr. Each operator and opâ€
5373 erand must be a separate argument. Expressions are composed of
5374 the primaries described above under CONDITIONAL EXPRESSIONS.
5375 test does not accept any options, nor does it accept and ignore
5376 an argument of -- as signifying the end of options.
5377
5378 Expressions may be combined using the following operators,
5379 listed in decreasing order of precedence. The evaluation
5380 depends on the number of arguments; see below. Operator preceâ€
5381 dence is used when there are five or more arguments.
5382 ! expr True if expr is false.
5383 ( expr )
5384 Returns the value of expr. This may be used to override
5385 the normal precedence of operators.
5386 expr1 -a expr2
5387 True if both expr1 and expr2 are true.
5388 expr1 -o expr2
5389 True if either expr1 or expr2 is true.
5390
5391 test and [ evaluate conditional expressions using a set of rules
5392 based on the number of arguments.
5393
5394 0 arguments
5395 The expression is false.
5396 1 argument
5397 The expression is true if and only if the argument is not
5398 null.
5399 2 arguments
5400 If the first argument is !, the expression is true if and
5401 only if the second argument is null. If the first arguâ€
5402 ment is one of the unary conditional operators listed
5403 above under CONDITIONAL EXPRESSIONS, the expression is
5404 true if the unary test is true. If the first argument is
5405 not a valid unary conditional operator, the expression is
5406 false.
5407 3 arguments
5408 The following conditions are applied in the order listed.
5409 If the second argument is one of the binary conditional
5410 operators listed above under CONDITIONAL EXPRESSIONS, the
5411 result of the expression is the result of the binary test
5412 using the first and third arguments as operands. The -a
5413 and -o operators are considered binary operators when
5414 there are three arguments. If the first argument is !,
5415 the value is the negation of the two-argument test using
5416 the second and third arguments. If the first argument is
5417 exactly ( and the third argument is exactly ), the result
5418 is the one-argument test of the second argument. Otherâ€
5419 wise, the expression is false.
5420 4 arguments
5421 If the first argument is !, the result is the negation of
5422 the three-argument expression composed of the remaining
5423 arguments. Otherwise, the expression is parsed and evalâ€
5424 uated according to precedence using the rules listed
5425 above.
5426 5 or more arguments
5427 The expression is parsed and evaluated according to
5428 precedence using the rules listed above.
5429
5430 When used with test or [, the < and > operators sort lexicoâ€
5431 graphically using ASCII ordering.
5432
5433 times Print the accumulated user and system times for the shell and
5434 for processes run from the shell. The return status is 0.
5435
5436 trap [-lp] [[arg] sigspec ...]
5437 The command arg is to be read and executed when the shell
5438 receives signal(s) sigspec. If arg is absent (and there is a
5439 single sigspec) or -, each specified signal is reset to its
5440 original disposition (the value it had upon entrance to the
5441 shell). If arg is the null string the signal specified by each
5442 sigspec is ignored by the shell and by the commands it invokes.
5443 If arg is not present and -p has been supplied, then the trap
5444 commands associated with each sigspec are displayed. If no
5445 arguments are supplied or if only -p is given, trap prints the
5446 list of commands associated with each signal. The -l option
5447 causes the shell to print a list of signal names and their corâ€
5448 responding numbers. Each sigspec is either a signal name
5449 defined in <signal.h>, or a signal number. Signal names are
5450 case insensitive and the SIG prefix is optional.
5451
5452 If a sigspec is EXIT (0) the command arg is executed on exit
5453 from the shell. If a sigspec is DEBUG, the command arg is exeâ€
5454 cuted before every simple command, for command, case command,
5455 select command, every arithmetic for command, and before the
5456 first command executes in a shell function (see SHELL GRAMMAR
5457 above). Refer to the description of the extdebug option to the
5458 shopt builtin for details of its effect on the DEBUG trap. If a
5459 sigspec is RETURN, the command arg is executed each time a shell
5460 function or a script executed with the . or source builtins finâ€
5461 ishes executing.
5462
5463 If a sigspec is ERR, the command arg is executed whenever a a
5464 pipeline (which may consist of a single simple command), a list,
5465 or a compound command returns a non-zero exit status, subject to
5466 the following conditions. The ERR trap is not executed if the
5467 failed command is part of the command list immediately following
5468 a while or until keyword, part of the test in an if statement,
5469 part of a command executed in a && or || list except the command
5470 following the final && or ||, any command in a pipeline but the
5471 last, or if the command's return value is being inverted using
5472 !. These are the same conditions obeyed by the errexit (-e)
5473 option.
5474
5475 Signals ignored upon entry to the shell cannot be trapped, reset
5476 or listed. Trapped signals that are not being ignored are reset
5477 to their original values in a subshell or subshell environment
5478 when one is created. The return status is false if any sigspec
5479 is invalid; otherwise trap returns true.
5480
5481 type [-aftpP] name [name ...]
5482 With no options, indicate how each name would be interpreted if
5483 used as a command name. If the -t option is used, type prints a
5484 string which is one of alias, keyword, function, builtin, or
5485 file if name is an alias, shell reserved word, function,
5486 builtin, or disk file, respectively. If the name is not found,
5487 then nothing is printed, and an exit status of false is
5488 returned. If the -p option is used, type either returns the
5489 name of the disk file that would be executed if name were speciâ€
5490 fied as a command name, or nothing if ``type -t name'' would not
5491 return file. The -P option forces a PATH search for each name,
5492 even if ``type -t name'' would not return file. If a command is
5493 hashed, -p and -P print the hashed value, which is not necessarâ€
5494 ily the file that appears first in PATH. If the -a option is
5495 used, type prints all of the places that contain an executable
5496 named name. This includes aliases and functions, if and only if
5497 the -p option is not also used. The table of hashed commands is
5498 not consulted when using -a. The -f option suppresses shell
5499 function lookup, as with the command builtin. type returns true
5500 if all of the arguments are found, false if any are not found.
5501
5502 ulimit [-HSTabcdefilmnpqrstuvx [limit]]
5503 Provides control over the resources available to the shell and
5504 to processes started by it, on systems that allow such control.
5505 The -H and -S options specify that the hard or soft limit is set
5506 for the given resource. A hard limit cannot be increased by a
5507 non-root user once it is set; a soft limit may be increased up
5508 to the value of the hard limit. If neither -H nor -S is speciâ€
5509 fied, both the soft and hard limits are set. The value of limit
5510 can be a number in the unit specified for the resource or one of
5511 the special values hard, soft, or unlimited, which stand for the
5512 current hard limit, the current soft limit, and no limit,
5513 respectively. If limit is omitted, the current value of the
5514 soft limit of the resource is printed, unless the -H option is
5515 given. When more than one resource is specified, the limit name
5516 and unit are printed before the value. Other options are interâ€
5517 preted as follows:
5518 -a All current limits are reported
5519 -b The maximum socket buffer size
5520 -c The maximum size of core files created
5521 -d The maximum size of a process's data segment
5522 -e The maximum scheduling priority ("nice")
5523 -f The maximum size of files written by the shell and its
5524 children
5525 -i The maximum number of pending signals
5526 -l The maximum size that may be locked into memory
5527 -m The maximum resident set size (many systems do not honor
5528 this limit)
5529 -n The maximum number of open file descriptors (most systems
5530 do not allow this value to be set)
5531 -p The pipe size in 512-byte blocks (this may not be set)
5532 -q The maximum number of bytes in POSIX message queues
5533 -r The maximum real-time scheduling priority
5534 -s The maximum stack size
5535 -t The maximum amount of cpu time in seconds
5536 -u The maximum number of processes available to a single
5537 user
5538 -v The maximum amount of virtual memory available to the
5539 shell and, on some systems, to its children
5540 -x The maximum number of file locks
5541 -T The maximum number of threads
5542
5543 If limit is given, and the -a option is not used, limit is the
5544 new value of the specified resource. If no option is given,
5545 then -f is assumed. Values are in 1024-byte increments, except
5546 for -t, which is in seconds; -p, which is in units of 512-byte
5547 blocks; and -T, -b, -n, and -u, which are unscaled values. The
5548 return status is 0 unless an invalid option or argument is supâ€
5549 plied, or an error occurs while setting a new limit. In POSIX
5550 Mode 512-byte blocks are used for the `-c' and `-f' options.
5551
5552 umask [-p] [-S] [mode]
5553 The user file-creation mask is set to mode. If mode begins with
5554 a digit, it is interpreted as an octal number; otherwise it is
5555 interpreted as a symbolic mode mask similar to that accepted by
5556 chmod(1). If mode is omitted, the current value of the mask is
5557 printed. The -S option causes the mask to be printed in symâ€
5558 bolic form; the default output is an octal number. If the -p
5559 option is supplied, and mode is omitted, the output is in a form
5560 that may be reused as input. The return status is 0 if the mode
5561 was successfully changed or if no mode argument was supplied,
5562 and false otherwise.
5563
5564 unalias [-a] [name ...]
5565 Remove each name from the list of defined aliases. If -a is
5566 supplied, all alias definitions are removed. The return value
5567 is true unless a supplied name is not a defined alias.
5568
5569 unset [-fv] [-n] [name ...]
5570 For each name, remove the corresponding variable or function.
5571 If the -v option is given, each name refers to a shell variable,
5572 and that variable is removed. Read-only variables may not be
5573 unset. If -f is specified, each name refers to a shell funcâ€
5574 tion, and the function definition is removed. If the -n option
5575 is supplied, and name is a variable with the nameref attribute,
5576 name will be unset rather than the variable it references. -n
5577 has no effect if the -f option is supplied. If no options are
5578 supplied, each name refers to a variable; if there is no variâ€
5579 able by that name, any function with that name is unset. Each
5580 unset variable or function is removed from the environment
5581 passed to subsequent commands. If any of COMP_WORDBREAKS, RANâ€
5582 DOM, SECONDS, LINENO, HISTCMD, FUNCNAME, GROUPS, or DIRSTACK are
5583 unset, they lose their special properties, even if they are subâ€
5584 sequently reset. The exit status is true unless a name is readâ€
5585 only.
5586
5587 wait [-n] [n ...]
5588 Wait for each specified child process and return its termination
5589 status. Each n may be a process ID or a job specification; if a
5590 job spec is given, all processes in that job's pipeline are
5591 waited for. If n is not given, all currently active child proâ€
5592 cesses are waited for, and the return status is zero. If the -n
5593 option is supplied, wait waits for any job to terminate and
5594 returns its exit status. If n specifies a non-existent process
5595 or job, the return status is 127. Otherwise, the return status
5596 is the exit status of the last process or job waited for.
5597
5598RESTRICTED SHELL
5599 If bash is started with the name rbash, or the -r option is supplied at
5600 invocation, the shell becomes restricted. A restricted shell is used
5601 to set up an environment more controlled than the standard shell. It
5602 behaves identically to bash with the exception that the following are
5603 disallowed or not performed:
5604
5605 · changing directories with cd
5606
5607 · setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV
5608
5609 · specifying command names containing /
5610
5611 · specifying a filename containing a / as an argument to the .
5612 builtin command
5613
5614 · specifying a filename containing a slash as an argument to the
5615 -p option to the hash builtin command
5616
5617 · importing function definitions from the shell environment at
5618 startup
5619
5620 · parsing the value of SHELLOPTS from the shell environment at
5621 startup
5622
5623 · redirecting output using the >, >|, <>, >&, &>, and >> redirectâ€
5624 ion operators
5625
5626 · using the exec builtin command to replace the shell with another
5627 command
5628
5629 · adding or deleting builtin commands with the -f and -d options
5630 to the enable builtin command
5631
5632 · using the enable builtin command to enable disabled shell
5633 builtins
5634
5635 · specifying the -p option to the command builtin command
5636
5637 · turning off restricted mode with set +r or set +o restricted.
5638
5639 These restrictions are enforced after any startup files are read.
5640
5641 When a command that is found to be a shell script is executed (see COMâ€
5642 MAND EXECUTION above), rbash turns off any restrictions in the shell
5643 spawned to execute the script.
5644
5645SEE ALSO
5646 Bash Reference Manual, Brian Fox and Chet Ramey
5647 The Gnu Readline Library, Brian Fox and Chet Ramey
5648 The Gnu History Library, Brian Fox and Chet Ramey
5649 Portable Operating System Interface (POSIX) Part 2: Shell and Utiliâ€
5650 ties, IEEE --
5651 http://pubs.opengroup.org/onlinepubs/9699919799/
5652 http://tiswww.case.edu/~chet/bash/POSIX -- a description of posix mode
5653 sh(1), ksh(1), csh(1)
5654 emacs(1), vi(1)
5655 readline(3)
5656
5657FILES
5658 /bin/bash
5659 The bash executable
5660 /etc/profile
5661 The systemwide initialization file, executed for login shells
5662 /etc/bash.bash_logout
5663 The systemwide login shell cleanup file, executed when a login
5664 shell exits
5665 ~/.bash_profile
5666 The personal initialization file, executed for login shells
5667 ~/.bashrc
5668 The individual per-interactive-shell startup file
5669 ~/.bash_logout
5670 The individual login shell cleanup file, executed when a login
5671 shell exits
5672 ~/.inputrc
5673 Individual readline initialization file
5674
5675AUTHORS
5676 Brian Fox, Free Software Foundation
5677 bfox@gnu.org
5678
5679 Chet Ramey, Case Western Reserve University
5680 chet.ramey@case.edu
5681
5682BUG REPORTS
5683 If you find a bug in bash, you should report it. But first, you should
5684 make sure that it really is a bug, and that it appears in the latest
5685 version of bash. The latest version is always available from
5686 ftp://ftp.gnu.org/pub/gnu/bash/.
5687
5688 Once you have determined that a bug actually exists, use the bashbug
5689 command (from the source package) to submit a bug report. If you have
5690 a fix, you are encouraged to mail that as well! Suggestions and
5691 `philosophical' bug reports may be mailed to bug-bash@gnu.org or posted
5692 to the Usenet newsgroup gnu.bash.bug.
5693
5694 ALL bug reports should include:
5695
5696 The version number of bash
5697 The hardware and operating system
5698 The compiler used to compile
5699 A description of the bug behaviour
5700 A short script or `recipe' which exercises the bug
5701
5702 Comments and bug reports concerning this manual page should be directed
5703 to chet.ramey@case.edu.
5704
5705BUGS
5706 It's too big and too slow.
5707
5708 There are some subtle differences between bash and traditional versions
5709 of sh, mostly because of the POSIX specification.
5710
5711 Aliases are confusing in some uses.
5712
5713 Shell builtin commands and functions are not stoppable/restartable.
5714
5715 Compound commands and command sequences of the form `a ; b ; c' are not
5716 handled gracefully when process suspension is attempted. When a
5717 process is stopped, the shell immediately executes the next command in
5718 the sequence. It suffices to place the sequence of commands between
5719 parentheses to force it into a subshell, which may be stopped as a
5720 unit.
5721
5722 Array variables may not (yet) be exported.
5723
5724 There may be only one active coprocess at a time.
5725
5726GNU Bash 4.3 2014 February 2 BASH(1)