1 This is the Bash FAQ, version 3.7, for Bash version 2.04.
3 This document contains a set of frequently-asked questions concerning
4 Bash, the GNU Bourne-Again Shell. Bash is a freely-available command
5 interpreter with advanced features for both interactive use and shell
8 Another good source of basic information about shells is the collection
9 of FAQ articles periodically posted to comp.unix.shell.
11 Questions and comments concerning this document should be sent to
14 This document is available for anonymous FTP with the URL
16 ftp://ftp.cwru.edu/pub/bash/FAQ
18 The Bash home page is http://cnswww.cns.cwru.edu/~chet/bash/bashtop.html
26 A2) What's the latest version?
27 A3) Where can I get it?
28 A4) On what machines will bash run?
29 A5) Will bash run on operating systems other than Unix?
30 A6) How can I build bash with gcc?
31 A7) How can I make bash my login shell?
32 A8) I just changed my login shell to bash, and now I can't FTP into my
34 A9) What's the `POSIX 1003.2 standard'?
35 A10) What is the bash `posix mode'?
37 Section B: The latest version
39 B1) What's new in version 2.04?
40 B2) Are there any user-visible incompatibilities between bash-2.04 and
43 Section C: Differences from other Unix shells
45 C1) How does bash differ from sh, the Bourne shell?
46 C2) How does bash differ from the Korn shell, version ksh88?
47 C3) Which new features in ksh-93 are not in bash, and which are?
49 Section D: Why does bash do some things differently than other Unix shells?
51 D1) Why does bash run a different version of `command' than
52 `which command' says it will?
53 D2) Why doesn't bash treat brace expansions exactly like csh?
54 D3) Why doesn't bash have csh variable modifiers?
55 D4) How can I make my csh aliases work when I convert to bash?
56 D5) How can I pipe standard output and standard error from one command to
57 another, like csh does with `|&'?
58 D6) Now that I've converted from ksh to bash, are there equivalents to
59 ksh features like autoloaded functions and the `whence' command?
61 Section E: Why does bash do certain things the way it does?
63 E1) Why is the bash builtin `test' slightly different from /bin/test?
64 E2) Why does bash sometimes say `Broken pipe'?
65 E3) When I have terminal escape sequences in my prompt, why does bash
66 wrap lines at the wrong column?
67 E4) If I pipe the output of a command into `read variable', why doesn't
68 the output show up in $variable when the read command finishes?
69 E5) I have a bunch of shell scripts that use backslash-escaped characters
70 in arguments to `echo'. Bash doesn't interpret these characters. Why
71 not, and how can I make it understand them?
72 E6) Why doesn't a while or for loop get suspended when I type ^Z?
74 Section F: Things to watch out for on certain Unix versions
76 F1) Why can't I use command line editing in my `cmdtool'?
77 F2) I built bash on Solaris 2. Why do globbing expansions and filename
78 completion chop off the first few characters of each filename?
79 F3) Why does bash dump core after I interrupt username completion or
80 `~user' tilde expansion on a machine running NIS?
81 F4) I'm running SVR4.2. Why is the line erased every time I type `@'?
82 F5) Why does bash report syntax errors when my C News scripts use a
83 redirection before a subshell command?
84 F6) Why can't I use vi-mode editing on Red Hat Linux 6.1?
86 Section G: How can I get bash to do certain common things?
88 G1) How can I get bash to read and display eight-bit characters?
89 G2) How do I write a function `x' to replace builtin command `x', but
90 still invoke the command from within the function?
91 G3) How can I find the value of a shell variable whose name is the value
92 of another shell variable?
93 G4) How can I make the bash `time' reserved word print timing output that
94 looks like the output from my system's /usr/bin/time?
95 G5) How do I get the current directory into my prompt?
96 G6) How can I rename "*.foo" to "*.bar"?
97 G7) How can I translate a filename from uppercase to lowercase?
98 G8) How can I write a filename expansion (globbing) pattern that will match
99 all files in the current directory except "." and ".."?
101 Section H: Where do I go from here?
103 H1) How do I report bugs in bash, and where should I look for fixes and
105 H2) What kind of bash documentation is there?
106 H3) What's coming in future versions?
107 H4) What's on the bash `wish list'?
108 H5) When will the next release appear?
111 Section A: The Basics
115 Bash is a Unix command interpreter (shell). It is an implementation of
116 the Posix 1003.2 shell standard, and resembles the Korn and System V
119 Bash contains a number of enhancements over those shells, both
120 for interactive use and shell programming. Features geared
121 toward interactive use include command line editing, command
122 history, job control, aliases, and prompt expansion. Programming
123 features include additional variable expansions, shell
124 arithmetic, and a number of variables and options to control
127 Bash was originally written by Brian Fox of the Free Software
128 Foundation. The current developer and maintainer is Chet Ramey
129 of Case Western Reserve University.
131 A2) What's the latest version?
133 The latest version is 2.04, first made available on Friday, 17 March 2000.
135 A3) Where can I get it?
137 Bash is the GNU project's shell, and so is available from the
138 master GNU archive site, ftp.gnu.org, and its mirrors. The
139 latest version is also available for FTP from ftp.cwru.edu.
140 The following URLs tell how to get version 2.04:
142 ftp://ftp.gnu.org/pub/gnu/bash/bash-2.04.tar.gz
143 ftp://ftp.cwru.edu/pub/bash/bash-2.04.tar.gz
145 Formatted versions of the documentation are available with the URLs:
147 ftp://ftp.gnu.org/pub/gnu/bash/bash-doc-2.04.tar.gz
148 ftp://ftp.cwru.edu/pub/bash/bash-doc-2.04.tar.gz
150 A4) On what machines will bash run?
152 Bash has been ported to nearly every version of UNIX. All you
153 should have to do to build it on a machine for which a port
154 exists is to type `configure' and then `make'. The build process
155 will attempt to discover the version of UNIX you have and tailor
156 itself accordingly, using a script created by GNU autoconf.
158 More information appears in the file `INSTALL' in the distribution.
160 A5) Will bash run on operating systems other than Unix?
162 Configuration specifics for Unix-like systems such as QNX and
163 LynxOS are included in the distribution. Bash-2.04 should
164 compile and run on Minix 2.0 (patches were contributed), but I
165 don't believe anyone has built bash-2.x on earlier Minix versions
168 Bash has been ported to versions of Windows implementing the Win32
169 programming interface. This includes Windows 95 and Windows NT.
170 The port was done by Cygnus Solutions as part of their CYGWIN
171 project. For more information about the project, look at the URL
173 http:/sourceware.cygnus.com/cygwin
175 Cygnus originally ported bash-1.14.7, and that port was part of their
176 early GNU-Win32 (the original name) releases. Cygnus has also done a
177 port of bash-2.02.1 to the CYGWIN environment, and it is available as
178 part of their current release. (They may have upgraded by now.)
180 Bash-2.04 should require no local Cygnus changes to build and run under
183 The Cygnus port works only on Intel machines. There is a port of bash
184 (I don't know which version) to the alpha/NT environment available from
186 ftp://ftp.gnustep.org//pub/win32/bash-alpha-nt-1.01.tar.gz
188 Softway Systems has ported bash-2.01 to their Interix (nee OpenNT)
189 system, a Unix subsystem for NT that replaces the Microsoft POSIX
190 subsystem. Check out http://www.interix.com for more information.
191 Some support for Interix has been incorporated into bash, beginning
192 with Bash-2.03. It should be easier to build bash on Interix now,
193 but Interix users should fetch
195 ftp://ftp.interix.com/pub/tw/unsup/bash.diffs.tar.gz
197 and read the README.OpenNT file in that archive. It will detail the
198 arguments `configure' needs to build on Interix. A configure cache
199 file for Interix is in the bash distribution in cross-build/opennt.cache;
200 copy that to `config.cache' before starting configure.
202 D. J. Delorie has ported bash-1.14.7 to run under MS-DOS, as part of
203 the DJGPP project. For more information on the project, see
205 http://www.delorie.com/djgpp/
207 I picked up a binary of bash-1.14.7 that is purported to work with
208 the DJGPP V2 environment from
210 ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh1147b.zip
212 The corresponding source is
214 ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh1147s.zip
216 Mark Elbrecht <snowball3@bigfoot.com> has sent me notice that bash-2.03
217 has become available for DJGPP V2. The files are available as:
219 ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh203b.zip binary
220 ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh203d.zip documentation
221 ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/bsh203s.zip source
223 Mark has begun to work with bash-2.04.
225 Ports of bash-1.12 and bash-2.0 are available for OS/2 from
227 ftp://hobbes.nmsu.edu/pub/os2/util/shell/bash_112.zip
228 ftp://hobbes.nmsu.edu/pub/os2/util/shell/bash-2.0(253).zip
230 I haven't looked at either, but the second appears to be a binary-only
231 distribution. Beware.
233 I have received word that Bash (I'm not sure which version, but I
234 believe that it's at least bash-2.02.1) is the standard shell on
237 A6) How can I build bash with gcc?
239 Bash configures to use gcc by default if it is available. Read the
240 file INSTALL in the distribution for more information.
242 A7) How can I make bash my login shell?
244 Some machines let you use `chsh' to change your login shell. Other
245 systems use `passwd -s' or `passwd -e'. If one of these works for
246 you, that's all you need. Note that many systems require the full
247 pathname to a shell to appear in /etc/shells before you can make it
248 your login shell. For this, you may need the assistance of your
249 friendly local system administrator.
251 If you cannot do this, you can still use bash as your login shell, but
252 you need to perform some tricks. The basic idea is to add a command
253 to your login shell's startup file to replace your login shell with
256 For example, if your login shell is csh or tcsh, and you have installed
257 bash in /usr/gnu/bin/bash, add the following line to ~/.login:
259 if ( -f /usr/gnu/bin/bash ) exec /usr/gnu/bin/bash --login
261 (the `--login' tells bash that it is a login shell).
263 It's not a good idea to put this command into ~/.cshrc, because every
264 csh you run without the `-f' option, even ones started to run csh scripts,
265 reads that file. If you must put the command in ~/.cshrc, use something
268 if ( $?prompt ) exec /usr/gnu/bin/bash --login
270 to ensure that bash is exec'd only when the csh is interactive.
272 If your login shell is sh or ksh, you have to do two things.
274 First, create an empty file in your home directory named `.bash_profile'.
275 The existence of this file will prevent the exec'd bash from trying to
276 read ~/.profile, and re-execing itself over and over again. ~/.bash_profile
277 is the first file bash tries to read initialization commands from when
278 it is invoked as a login shell.
280 Next, add a line similar to the above to ~/.profile:
282 [ -f /usr/gnu/bin/bash ] && exec /usr/gnu/bin/bash --login
284 This will cause login shells to replace themselves with bash running as
285 a login shell. Once you have this working, you can copy your initialization
286 code from ~/.profile to ~/.bash_profile.
288 I have received word that the recipe supplied above is insufficient for
289 machines running CDE. CDE has a maze of twisty little startup files, all
292 If you cannot change your login shell in the password file to bash, you
293 will have to (apparently) live with CDE using the shell in the password
294 file to run its startup scripts. If you have changed your shell to bash,
295 there is code in the CDE startup files (on Solaris, at least) to do the
298 `dtterm' claims to use $SHELL as the default program to start, so if you
299 can change $SHELL in the CDE startup files, you should be able to use bash
300 in your terminal windows.
302 Setting DTSOURCEPROFILE in ~/.dtprofile will cause the `Xsession' program
303 to read your login shell's startup files. You may be able to use bash for
304 the rest of the CDE programs by setting SHELL to bash in ~/.dtprofile as
305 well, but I have not tried this.
307 You can use the above `exec' recipe to start bash when not logging in with
308 CDE by testing the value of the DT variable:
310 if [ -n "$DT" ]; then
311 [ -f /usr/gnu/bin/bash ] && exec /usr/gnu/bin/bash --login
315 A8) I just changed my login shell to bash, and now I can't FTP into my
318 You must add the full pathname to bash to the file /etc/shells. As
319 noted in the answer to the previous question, many systems require
320 this before you can make bash your login shell.
322 Most versions of ftpd use this file to prohibit `special' users
323 such as `uucp' and `news' from using FTP.
325 A9) What's the `POSIX 1003.2 standard'?
327 POSIX is a name originally coined by Richard Stallman for a
328 family of open system standards based on UNIX. There are a
329 number of aspects of UNIX under consideration for
330 standardization, from the basic system services at the system
331 call and C library level to applications and tools to system
332 administration and management. Each area of standardization is
333 assigned to a working group in the 1003 series.
335 The POSIX Shell and Utilities standard has been developed by IEEE
336 Working Group 1003.2 (POSIX.2). It concentrates on the command
337 interpreter interface and utility programs commonly executed from
338 the command line or by other programs. An initial version of the
339 standard has been approved and published by the IEEE, and work is
340 currently underway to update it.
342 Bash is concerned with the aspects of the shell's behavior
343 defined by POSIX.2. The shell command language has of course
344 been standardized, including the basic flow control and program
345 execution constructs, I/O redirection and pipelining, argument
346 handling, variable expansion, and quoting.
348 The `special' builtins, which must be implemented as part of the
349 shell to provide the desired functionality, are specified as
350 being part of the shell; examples of these are `eval' and
351 `export'. Other utilities appear in the sections of POSIX.2 not
352 devoted to the shell which are commonly (and in some cases must
353 be) implemented as builtin commands, such as `read' and `test'.
354 POSIX.2 also specifies aspects of the shell's interactive
355 behavior as part of the UPE, including job control and command
356 line editing. Only vi-style line editing commands have been
357 standardized; emacs editing commands were left out due to
360 A10) What is the bash `posix mode'?
362 Although bash is an implementation of the POSIX.2 shell
363 specification, there are areas where the bash default behavior
364 differs from that spec. The bash `posix mode' changes the bash
365 behavior in these areas so that it obeys the spec more closely.
367 Posix mode is entered by starting bash with the --posix option or
368 executing `set -o posix' after bash is running.
370 The specific aspects of bash which change when posix mode is
371 active are listed in the file CWRU/POSIX.NOTES in the bash
372 distribution. They are also listed in a section in the Bash
375 Section B: The latest version
377 B1) What's new in version 2.04?
379 Bash-2.04 contains the following new features (see the manual page for
380 complete descriptions and the CHANGES and NEWS files in the bash-2.04
383 o Programmable word completion with the new `complete' and `compgen' builtins;
384 examples are provided in examples/complete/complete-examples
385 o `history' has a new `-d' option to delete a history entry
386 o `bind' has a new `-x' option to bind key sequences to shell commands
387 o The prompt expansion code has new `\j' and `\l' escape sequences
388 o The `no_empty_command_completion' shell option, if enabled, inhibits
389 command completion when TAB is typed on an empty line
390 o `help' has a new `-s' option to print a usage synopsis
391 o New arithmetic operators: var++, var--, ++var, --var, expr1,expr2 (comma)
392 o New ksh93-style arithmetic for command:
393 for ((expr1 ; expr2; expr3 )); do list; done
394 o `read' has new options: `-t', `-n', `-d', `-s'
395 o The redirection code handles several filenames specially: /dev/fd/N,
396 /dev/stdin, /dev/stdout, /dev/stderr
397 o The redirection code now recognizes /dev/tcp/HOST/PORT and
398 /dev/udp/HOST/PORT and tries to open a TCP or UDP socket, respectively,
399 to the specified port on the specified host
400 o The ${!prefix*} expansion has been implemented
401 o A new FUNCNAME variable, which expands to the name of a currently-executing
403 o The GROUPS variable is no longer readonly
404 o A new shopt `xpg_echo' variable, to control the behavior of echo with
405 respect to backslash-escape sequences at runtime
406 o The NON_INTERACTIVE_LOGIN_SHELLS #define has returned
408 The version of Readline released with Bash-2.04, Readline-4.1, has several
409 new features as well:
411 o Parentheses matching is always compiled into readline, and controllable
412 with the new `blink-matching-paren' variable
413 o The history-search-forward and history-search-backward functions now leave
414 point at the end of the line when the search string is empty, like
415 reverse-search-history, and forward-search-history
416 o A new function for applications: rl_on_new_line_with_prompt()
417 o New variables for applications: rl_already_prompted, and rl_gnu_readline_p
420 A short feature history dating from bash-2.0:
422 Bash-2.03 had very few new features, in keeping with the convention
423 that odd-numbered releases provide mainly bug fixes. A number of new
424 features were added to Readline, mostly at the request of the Cygnus
427 A new shopt option, `restricted_shell', so that startup files can test
428 whether or not the shell was started in restricted mode
429 Filename generation is now performed on the words between ( and ) in
430 compound array assignments (this is really a bug fix)
431 OLDPWD is now auto-exported, as POSIX.2 requires
432 ENV and BASH_ENV are read-only variables in a restricted shell
433 Bash may now be linked against an already-installed Readline library,
434 as long as the Readline library is version 4 or newer
435 All shells begun with the `--login' option will source the login shell
436 startup files, even if the shell is not interactive
438 There were lots of changes to the version of the Readline library released
439 along with Bash-2.03. For a complete list of the changes, read the file
440 CHANGES in the Bash-2.03 distribution.
442 Bash-2.02 contained the following new features:
444 a new version of malloc (based on the old GNU malloc code in previous
445 bash versions) that is more page-oriented, more conservative
446 with memory usage, does not `orphan' large blocks when they
447 are freed, is usable on 64-bit machines, and has allocation
448 checking turned on unconditionally
449 POSIX.2-style globbing character classes ([:alpha:], [:alnum:], etc.)
450 POSIX.2-style globbing equivalence classes
451 POSIX.2-style globbing collating symbols
452 the ksh [[...]] extended conditional command
453 the ksh egrep-style extended pattern matching operators
454 a new `printf' builtin
455 the ksh-like $(<filename) command substitution, which is equivalent to
457 new tilde prefixes that expand to directories from the directory stack
458 new `**' arithmetic operator to do exponentiation
459 case-insensitive globbing (filename expansion)
460 menu completion a la tcsh
461 `magic-space' history expansion function like tcsh
462 the readline inputrc `language' has a new file inclusion directive ($include)
464 Bash-2.01 contained only a few new features:
466 new `GROUPS' builtin array variable containing the user's group list
467 new bindable readline commands: history-and-alias-expand-line and
470 Bash-2.0 contained extensive changes and new features from bash-1.14.7.
473 new `time' reserved word to time pipelines, shell builtins, and
475 one-dimensional arrays with a new compound assignment statement,
476 appropriate expansion constructs and modifications to some
477 of the builtins (read, declare, etc.) to use them
478 new quoting syntaxes for ANSI-C string expansion and locale-specific
480 new expansions to do substring extraction, pattern replacement, and
481 indirect variable expansion
482 new builtins: `disown' and `shopt'
483 new variables: HISTIGNORE, SHELLOPTS, PIPESTATUS, DIRSTACK, GLOBIGNORE,
484 MACHTYPE, BASH_VERSINFO
485 special handling of many unused or redundant variables removed
486 (e.g., $notify, $glob_dot_filenames, $no_exit_on_failed_exec)
487 dynamic loading of new builtin commands; many loadable examples provided
488 new prompt expansions: \a, \e, \n, \H, \T, \@, \v, \V
489 history and aliases available in shell scripts
490 new readline variables: enable-keypad, mark-directories, input-meta,
491 visible-stats, disable-completion, comment-begin
492 new readline commands to manipulate the mark and operate on the region
493 new readline emacs mode commands and bindings for ksh-88 compatibility
494 updated and extended builtins
496 expanded (and now documented) restricted shell mode
498 implementation stuff:
499 autoconf-based configuration
500 nearly all of the bugs reported since version 1.14 have been fixed
501 most builtins converted to use builtin `getopt' for consistency
502 most builtins use -p option to display output in a reusable form
504 grammar tighter and smaller (66 reduce-reduce conflicts gone)
505 lots of code now smaller and faster
506 test suite greatly expanded
508 B2) Are there any user-visible incompatibilities between bash-2.04 and
511 There are a few incompatibilities between version 1.14.7 and version 2.04.
512 They are detailed in the file COMPAT in the bash-2.04 distribution.
514 Section C: Differences from other Unix shells
516 C1) How does bash differ from sh, the Bourne shell?
518 This is a non-comprehensive list of features that differentiate bash
519 from the SVR4.2 shell. The bash manual page explains these more
522 Things bash has that sh does not:
523 long invocation options
524 `!' reserved word to invert pipeline return value
525 `time' reserved word to time pipelines and shell builtins
526 the `function' reserved word
527 the `select' compound command and reserved word
528 arithmetic for command: for ((expr1 ; expr2; expr3 )); do list; done
529 new $'...' and $"..." quoting
530 the $(...) form of command substitution
531 the $(<filename) form of command substitution, equivalent to
533 the ${#param} parameter value length operator
534 the ${!param} indirect parameter expansion operator
535 the ${!param*} prefix expansion operator
536 the ${param:length[:offset]} parameter substring operator
537 the ${param/pat[/string]} parameter pattern substitution operator
538 expansions to perform substring removal (${p%[%]w}, ${p#[#]w})
539 expansion of positional parameters beyond $9 with ${num}
540 variables: BASH, BASH_VERSION, BASH_VERSINFO, UID, EUID, REPLY,
541 TIMEFORMAT, PPID, PWD, OLDPWD, SHLVL, RANDOM, SECONDS,
542 LINENO, HISTCMD, HOSTTYPE, OSTYPE, MACHTYPE, HOSTNAME,
543 ENV, PS3, PS4, DIRSTACK, PIPESTATUS, HISTSIZE, HISTFILE,
544 HISTFILESIZE, HISTCONTROL, HISTIGNORE, GLOBIGNORE, GROUPS,
545 PROMPT_COMMAND, FCEDIT, FIGNORE, IGNOREEOF, INPUTRC,
546 SHELLOPTS, OPTERR, HOSTFILE, TMOUT, FUNCNAME, histchars,
549 variable arrays with new compound assignment syntax
550 redirections: <>, &>, >|
551 prompt string special char translation and variable expansion
552 auto-export of variables in initial environment
553 command search finds functions before builtins
554 bash return builtin will exit a file sourced with `.'
555 builtins: cd -/-L/-P, exec -l/-c/-a, echo -e/-E, hash -p.
556 export -n/-f/-p/name=value, pwd -L/-P,
557 read -e/-p/-a/-t/-n/-d/-s,
558 readonly -a/-f/name=value, trap -l, set +o,
559 set -b/-m/-o option/-h/-p/-B/-C/-H/-P,
560 unset -f/-v, ulimit -m/-p/-u,
561 type -a/-p/-t, suspend -f, kill -n,
562 test -o optname/s1 == s2/s1 < s2/s1 > s2/-nt/-ot/-ef/-O/-G/-S
563 bash reads ~/.bashrc for interactive shells, $ENV for non-interactive
564 bash restricted shell mode is more extensive
565 bash allows functions and variables with the same name
568 arithmetic expansion with $((...)) and `let' builtin
569 the `[[...]]' extended conditional command
571 aliases and alias/unalias builtins
572 local variables in functions and `local' builtin
573 readline and command-line editing with programmable completion
574 command history and history/fc builtins
575 csh-like history expansion
576 other new bash builtins: bind, command, compgen, complete, builtin,
577 declare/typeset, dirs, enable, fc, help,
578 history, logout, popd, pushd, disown, shopt,
581 filename generation when using output redirection (command >a*)
582 POSIX.2-style globbing character classes
583 POSIX.2-style globbing equivalence classes
584 POSIX.2-style globbing collating symbols
585 egrep-like extended pattern matching operators
586 case-insensitive pattern matching and globbing
587 variable assignments preceding commands affect only that command,
588 even for builtins and functions
590 redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr,
591 /dev/tcp/host/port, /dev/udp/host/port
593 Things sh has that bash does not:
594 uses variable SHACCT to do shell accounting
595 includes `stop' builtin (bash can use alias stop='kill -s STOP')
597 turns on job control if called as `jsh'
598 $TIMEOUT (like bash $TMOUT)
599 `^' is a synonym for `|'
600 new SVR4.2 sh builtins: mldmode, priv
602 Implementation differences:
603 redirection to/from compound commands causes sh to create a subshell
604 bash does not allow unbalanced quotes; sh silently inserts them at EOF
605 bash does not mess with signal 11
606 sh sets (euid, egid) to (uid, gid) if -p not supplied and uid < 100
607 bash splits only the results of expansions on IFS, using POSIX.2
608 field splitting rules; sh splits all words on IFS
609 sh does not allow MAILCHECK to be unset (?)
610 sh does not allow traps on SIGALRM or SIGCHLD
611 bash allows multiple option arguments when invoked (e.g. -x -v);
612 sh allows only a single option argument (`sh -x -v' attempts
613 to open a file named `-v', and, on SunOS 4.1.4, dumps core.
614 On Solaris 2.4 and earlier versions, sh goes into an infinite
616 sh exits a script if any builtin fails; bash exits only if one of
617 the POSIX.2 `special' builtins fails
619 C2) How does bash differ from the Korn shell, version ksh88?
621 Things bash has or uses that ksh88 does not:
622 long invocation options
624 arithmetic for command: for ((expr1 ; expr2; expr3 )); do list; done
625 posix mode and posix conformance
627 tilde expansion for assignment statements that look like $PATH
628 process substitution with named pipes if /dev/fd is not available
629 the ${!param} indirect parameter expansion operator
630 the ${!param*} prefix expansion operator
631 the ${param:length[:offset]} parameter substring operator
632 the ${param/pat[/string]} parameter pattern substitution operator
633 variables: BASH, BASH_VERSION, BASH_VERSINFO, UID, EUID, SHLVL,
634 TIMEFORMAT, HISTCMD, HOSTTYPE, OSTYPE, MACHTYPE,
635 HISTFILESIZE, HISTIGNORE, HISTCONTROL, PROMPT_COMMAND,
636 IGNOREEOF, FIGNORE, INPUTRC, HOSTFILE, DIRSTACK,
637 PIPESTATUS, HOSTNAME, OPTERR, SHELLOPTS, GLOBIGNORE,
638 GROUPS, FUNCNAME, histchars, auto_resume
639 prompt expansion with backslash escapes and command substitution
640 redirection: &> (stdout and stderr)
641 more extensive and extensible editing and programmable completion
642 builtins: bind, builtin, command, declare, dirs, echo -e/-E, enable,
643 exec -l/-c/-a, fc -s, export -n/-f/-p, hash, help, history,
644 jobs -x/-r/-s, kill -s/-n/-l, local, logout, popd, pushd,
645 read -e/-p/-a/-t/-n/-d/-s, readonly -a/-n/-f/-p,
646 set -o braceexpand/-o histexpand/-o interactive-comments/
647 -o notify/-o physical/-o posix/-o hashall/-o onecmd/
648 -h/-B/-C/-b/-H/-P, set +o, suspend, trap -l, type,
649 typeset -a/-F/-p, ulimit -u, umask -S, alias -p, shopt,
650 disown, printf, complete, compgen
651 `!' csh-style history expansion
652 POSIX.2-style globbing character classes
653 POSIX.2-style globbing equivalence classes
654 POSIX.2-style globbing collating symbols
655 egrep-like extended pattern matching operators
656 case-insensitive pattern matching and globbing
657 `**' arithmetic operator to do exponentiation
658 redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr
660 Things ksh88 has or uses that bash does not:
662 variables: ERRNO, FPATH, EDITOR, VISUAL
663 co-processes (|&, >&p, <&p)
664 weirdly-scoped functions
665 typeset +f to list all function names without definitions
666 text of command history kept in a file, not memory
667 builtins: alias -x, cd old new, fc -e -, newgrp, print,
668 read -p/-s/-u/var?prompt, set -A/-o gmacs/
669 -o bgnice/-o markdirs/-o nolog/-o trackall/-o viraw/-s,
670 typeset -H/-L/-R/-A/-ft/-fu/-fx/-l/-u/-t, whence
672 Implementation differences:
673 ksh runs last command of a pipeline in parent shell context
674 bash has brace expansion by default (ksh88 compile-time option)
675 bash has fixed startup file for all interactive shells; ksh reads $ENV
676 bash has exported functions
677 bash command search finds functions before builtins
679 C3) Which new features in ksh-93 are not in bash, and which are?
681 New things in ksh-93 not in bash-2.04:
683 floating point arithmetic
684 math library functions
685 ${!name[sub]} name of subscript for associative array
686 `.' is allowed in variable names to create a hierarchical namespace
687 more extensive compound assignment syntax
689 `sleep' and `getconf' builtins (bash has loadable versions)
690 typeset -n and `nameref' variables
692 variables: .sh.edchar, .sh.edmode, .sh.edcol, .sh.edtext, .sh.version,
693 .sh.name, .sh.subscript, .sh.value, HISTEDIT
694 backreferences in pattern matching
695 print -f (bash uses printf)
696 `fc' has been renamed to `hist'
697 `.' can execute shell functions
699 New things in ksh-93 present in bash-2.04:
700 for (( expr1; expr2; expr3 )) ; do list; done - arithmetic for command
701 ?:, ++, --, `expr1 , expr2' arithmetic operators
702 expansions: ${!param}, ${param:offset[:len]}, ${param/pat[/str]},
704 compound array assignment
705 the `!' reserved word
706 loadable builtins -- but ksh uses `builtin' while bash uses `enable'
707 `command', `builtin', `disown' builtins
708 new $'...' and $"..." quoting
709 FIGNORE (but bash uses GLOBIGNORE), HISTCMD
711 changes to kill builtin
712 read -A (bash uses read -a)
716 `.' restores the positional parameters when it completes
720 command and arithmetic substitution performed on PS1, PS4, and ENV
721 command name completion
722 ENV processed only for interactive shells
724 Section D: Why does bash do some things differently than other Unix shells?
726 D1) Why does bash run a different version of `command' than
727 `which command' says it will?
729 On many systems, `which' is actually a csh script that assumes
730 you're running csh. In tcsh, `which' and its cousin `where'
731 are builtins. On other Unix systems, `which' is a perl script
732 that uses the PATH environment variable.
734 The csh script version reads the csh startup files from your
735 home directory and uses those to determine which `command' will
736 be invoked. Since bash doesn't use any of those startup files,
737 there's a good chance that your bash environment differs from
738 your csh environment. The bash `type' builtin does everything
739 `which' does, and will report correct results for the running
740 shell. If you're really wedded to the name `which', try adding
741 the following function definition to your .bashrc:
748 If you're moving from tcsh and would like to bring `where' along
749 as well, use this function:
756 D2) Why doesn't bash treat brace expansions exactly like csh?
758 The only difference between bash and csh brace expansion is that
759 bash requires a brace expression to contain at least one unquoted
760 comma if it is to be expanded. Any brace-surrounded word not
761 containing an unquoted comma is left unchanged by the brace
762 expansion code. This affords the greatest degree of sh
765 Bash, ksh, zsh, and pd-ksh all implement brace expansion this way.
767 D3) Why doesn't bash have csh variable modifiers?
769 Posix has specified a more powerful, albeit somewhat more cryptic,
770 mechanism cribbed from ksh, and bash implements it.
773 Remove smallest suffix pattern. The WORD is expanded to produce
774 a pattern. It then expands to the value of PARAMETER, with the
775 smallest portion of the suffix matched by the pattern deleted.
783 Remove largest suffix pattern. The WORD is expanded to produce
784 a pattern. It then expands to the value of PARAMETER, with the
785 largest portion of the suffix matched by the pattern deleted.
792 Remove smallest prefix pattern. The WORD is expanded to produce
793 a pattern. It then expands to the value of PARAMETER, with the
794 smallest portion of the prefix matched by the pattern deleted.
801 Remove largest prefix pattern. The WORD is expanded to produce
802 a pattern. It then expands to the value of PARAMETER, with the
803 largest portion of the prefix matched by the pattern deleted.
822 D4) How can I make my csh aliases work when I convert to bash?
824 Bash uses a different syntax to support aliases than csh does.
825 The details can be found in the documentation. We have provided
826 a shell script which does most of the work of conversion for you;
827 this script can be found in ./examples/misc/alias-conv.sh. Here is
830 Start csh in the normal way for you. (e.g., `csh')
832 Pipe the output of `alias' through `alias-conv.sh', saving the
833 results into `bash_aliases':
835 alias | alias-conv.sh >bash_aliases
837 Edit `bash_aliases', carefully reading through any created
838 functions. You will need to change the names of some csh specific
839 variables to the bash equivalents. The script converts $cwd to
840 $PWD, $term to $TERM, $home to $HOME, $user to $USER, and $prompt
841 to $PS1. You may also have to add quotes to avoid unwanted
844 For example, the csh alias:
846 alias cd 'cd \!*; echo $cwd'
848 is converted to the bash function:
850 cd () { command cd "$@"; echo $PWD ; }
852 The only thing that needs to be done is to quote $PWD:
854 cd () { command cd "$@"; echo "$PWD" ; }
856 Merge the edited file into your ~/.bashrc.
858 There is an additional, more ambitious, script in
859 examples/misc/cshtobash that attempts to convert your entire csh
860 environment to its bash equivalent. This script can be run as
861 simply `cshtobash' to convert your normal interactive
862 environment, or as `cshtobash ~/.login' to convert your login
865 D5) How can I pipe standard output and standard error from one command to
866 another, like csh does with `|&'?
869 command 2>&1 | command2
871 The key is to remember that piping is performed before redirection, so
872 file descriptor 1 points to the pipe when it is duplicated onto file
875 D6) Now that I've converted from ksh to bash, are there equivalents to
876 ksh features like autoloaded functions and the `whence' command?
878 There are features in ksh-88 and ksh-93 that do not have direct bash
879 equivalents. Most, however, can be emulated with very little trouble.
881 ksh-88 feature Bash equivalent
882 -------------- ---------------
883 compiled-in aliases set up aliases in .bashrc; some ksh aliases are
884 bash builtins (hash, history, type)
885 coprocesses named pipe pairs (one for read, one for write)
886 typeset +f declare -F
887 cd, print, whence function substitutes in examples/functions/kshenv
888 autoloaded functions examples/functions/autoload is the same as typeset -fu
889 read var?prompt read -p prompt var
891 ksh-93 feature Bash equivalent
892 -------------- ---------------
893 sleep, getconf Bash has loadable versions in examples/loadables
894 ${.sh.version} $BASH_VERSION
899 Section E: How can I get bash to do certain things, and why does bash do
900 things the way it does?
902 E1) Why is the bash builtin `test' slightly different from /bin/test?
904 The specific example used here is [ ! x -o x ], which is false.
906 Bash's builtin `test' implements the Posix.2 spec, which can be
907 summarized as follows (the wording is due to David Korn):
909 Here is the set of rules for processing test arguments.
912 1 Arg: True iff argument is not null.
913 2 Args: If first arg is !, True iff second argument is null.
914 If first argument is unary, then true if unary test is true
916 3 Args: If second argument is a binary operator, do binary test of $1 $3
917 If first argument is !, negate two argument test of $2 $3
918 If first argument is `(' and third argument is `)', do the
919 one-argument test of the second argument.
921 4 Args: If first argument is !, negate three argument test of $2 $3 $4.
922 Otherwise unspecified
923 5 or more Args: unspecified. (Historical shells would use their
926 The operators -a and -o are considered binary operators for the purpose
929 As you can see, the test becomes (not (x or x)), which is false.
931 E2) Why does bash sometimes say `Broken pipe'?
933 If a sequence of commands appears in a pipeline, and one of the
934 reading commands finishes before the writer has finished, the
935 writer receives a SIGPIPE signal. Many other shells special-case
936 SIGPIPE as an exit status in the pipeline and do not report it.
941 `head' can finish before `ps' writes all of its output, and ps
942 will try to write on a pipe without a reader. In that case, bash
943 will print `Broken pipe' to stderr when ps is killed by a
946 You can build a version of bash that will not report SIGPIPE errors
947 by uncommenting the definition of DONT_REPORT_SIGPIPE in the file
950 E3) When I have terminal escape sequences in my prompt, why does bash
951 wrap lines at the wrong column?
953 Readline, the line editing library that bash uses, does not know
954 that the terminal escape sequences do not take up space on the
955 screen. The redisplay code assumes, unless told otherwise, that
956 each character in the prompt is a `printable' character that
957 takes up one character position on the screen.
959 You can use the bash prompt expansion facility (see the PROMPTING
960 section in the manual page) to tell readline that sequences of
961 characters in the prompt strings take up no screen space.
963 Use the \[ escape to begin a sequence of non-printing characters,
964 and the \] escape to signal the end of such a sequence.
966 E4) If I pipe the output of a command into `read variable', why doesn't
967 the output show up in $variable when the read command finishes?
969 This has to do with the parent-child relationship between Unix
972 Each element of a pipeline runs in a separate process, a child of
973 the shell running the pipeline. A subprocess cannot affect its
974 parent's environment. When the `read' command sets the variable
975 to the input, that variable is set only in the subshell, not the
976 parent shell. When the subshell exits, the value of the variable
979 Many pipelines that end with `read variable' can be converted
980 into command substitutions, which will capture the output of
981 a specified command. The output can then be assigned to a
984 grep ^gnu /usr/lib/news/active | wc -l | read ngroup
986 can be converted into
988 ngroup=$(grep ^gnu /usr/lib/news/active | wc -l)
990 This does not, unfortunately, work to split the text among
991 multiple variables, as read does when given multiple variable
992 arguments. If you need to do this, you can either use the
993 command substitution above to read the output into a variable
994 and chop up the variable using the bash pattern removal
995 expansion operators or use some variant of the following
998 Say /usr/local/bin/ipaddr is the following shell script:
1001 host `hostname` | awk '/address/ {print $NF}'
1005 /usr/local/bin/ipaddr | read A B C D
1007 to break the local machine's IP address into separate octets, use
1011 set -- $(/usr/local/bin/ipaddr)
1013 A="$1" B="$2" C="$3" D="$4"
1015 Beware, however, that this will change the shell's positional
1016 parameters. If you need them, you should save them before doing
1019 This is the general approach -- in most cases you will not need to
1020 set $IFS to a different value.
1022 E5) I have a bunch of shell scripts that use backslash-escaped characters
1023 in arguments to `echo'. Bash doesn't interpret these characters. Why
1024 not, and how can I make it understand them?
1026 This is the behavior of echo on most Unix System V machines.
1028 The bash builtin `echo' is modeled after the 9th Edition
1029 Research Unix version of `echo'. It does not interpret
1030 backslash-escaped characters in its argument strings by default;
1031 it requires the use of the -e option to enable the
1032 interpretation. The System V echo provides no way to disable the
1033 special characters; the bash echo has a -E option to disable
1036 There is a configuration option that will make bash behave like
1037 the System V echo and interpret things like `\t' by default. Run
1038 configure with the --enable-usg-echo-default option to turn this
1039 on. Be aware that this will cause some of the tests run when you
1040 type `make tests' to fail.
1042 There is a shell option, `xpg_echo', settable with `shopt' that will
1043 change the behavior of echo at runtime. Enabling this option turns
1044 on expansion of backslash-escape sequences.
1046 E6) Why doesn't a while or for loop get suspended when I type ^Z?
1048 This is a consequence of how job control works on Unix. The only
1049 thing that can be suspended is the process group. This is a single
1050 command or pipeline of commands that the shell forks and executes.
1052 When you run a while or for loop, the only thing that the shell forks
1053 and executes are any commands in the while loop test and commands in
1054 the loop bodies. These, therefore, are the only things that can be
1055 suspended when you type ^Z.
1057 If you want to be able to stop the entire loop, you need to put it
1058 within parentheses, which will force the loop into a subshell that
1059 may be stopped (and subsequently restarted) as a single unit.
1061 Section F: Things to watch out for on certain Unix versions
1063 F1) Why can't I use command line editing in my `cmdtool'?
1065 The problem is `cmdtool' and bash fighting over the input. When
1066 scrolling is enabled in a cmdtool window, cmdtool puts the tty in
1067 `raw mode' to permit command-line editing using the mouse for
1068 applications that cannot do it themselves. As a result, bash and
1069 cmdtool each try to read keyboard input immediately, with neither
1070 getting enough of it to be useful.
1072 This mode also causes cmdtool to not implement many of the
1073 terminal functions and control sequences appearing in the
1074 `sun-cmd' termcap entry. For a more complete explanation, see
1075 that file examples/suncmd.termcap in the bash distribution.
1077 `xterm' is a better choice, and gets along with bash much more
1080 If you must use cmdtool, you can use the termcap description in
1081 examples/suncmd.termcap. Set the TERMCAP variable to the terminal
1082 description contained in that file, i.e.
1084 TERMCAP='Mu|sun-cmd:am:bs:km:pt:li#34:co#80:cl=^L:ce=\E[K:cd=\E[J:rs=\E[s:'
1086 Then export TERMCAP and start a new cmdtool window from that shell.
1087 The bash command-line editing should behave better in the new
1088 cmdtool. If this works, you can put the assignment to TERMCAP
1089 in your bashrc file.
1091 F2) I built bash on Solaris 2. Why do globbing expansions and filename
1092 completion chop off the first few characters of each filename?
1094 This is the consequence of building bash on SunOS 5 and linking
1095 with the libraries in /usr/ucblib, but using the definitions
1096 and structures from files in /usr/include.
1098 The actual conflict is between the dirent structure in
1099 /usr/include/dirent.h and the struct returned by the version of
1100 `readdir' in libucb.a (a 4.3-BSD style `struct direct').
1102 Make sure you've got /usr/ccs/bin ahead of /usr/ucb in your $PATH
1103 when configuring and building bash. This will ensure that you
1104 use /usr/ccs/bin/cc or acc instead of /usr/ucb/cc and that you
1105 link with libc before libucb.
1107 If you have installed the Sun C compiler, you may also need to
1108 put /usr/ccs/bin and /opt/SUNWspro/bin into your $PATH before
1111 F3) Why does bash dump core after I interrupt username completion or
1112 `~user' tilde expansion on a machine running NIS?
1114 This is a famous and long-standing bug in the SunOS YP (sorry, NIS)
1115 client library, which is part of libc.
1117 The YP library code keeps static state -- a pointer into the data
1118 returned from the server. When YP initializes itself (setpwent),
1119 it looks at this pointer and calls free on it if it's non-null.
1122 If one of the YP functions is interrupted during getpwent (the
1123 exact function is interpretwithsave()), and returns NULL, the
1124 pointer is freed without being reset to NULL, and the function
1125 returns. The next time getpwent is called, it sees that this
1126 pointer is non-null, calls free, and the bash free() blows up
1127 because it's being asked to free freed memory.
1129 The traditional Unix mallocs allow memory to be freed multiple
1130 times; that's probably why this has never been fixed. You can
1131 run configure with the `--without-gnu-malloc' option to use
1132 the C library malloc and avoid the problem.
1134 F4) I'm running SVR4.2. Why is the line erased every time I type `@'?
1136 The `@' character is the default `line kill' character in most
1137 versions of System V, including SVR4.2. You can change this
1138 character to whatever you want using `stty'. For example, to
1139 change the line kill character to control-u, type
1143 where the `^' and `U' can be two separate characters.
1145 F5) Why does bash report syntax errors when my C News scripts use a
1146 redirection before a subshell command?
1148 The actual command in question is something like
1152 According to the grammar given in the POSIX.2 standard, this construct
1153 is, in fact, a syntax error. Redirections may only precede `simple
1154 commands'. A subshell construct such as the above is one of the shell's
1155 `compound commands'. A redirection may only follow a compound command.
1157 This affects the mechanical transformation of commands that use `cat'
1158 to pipe a file into a command (a favorite Useless-Use-Of-Cat topic on
1159 comp.unix.shell). While most commands of the form
1163 can be converted to `< file command', shell control structures such as
1164 loops and subshells require `command < file'.
1166 The file CWRU/sh-redir-hack in the bash-2.04 distribution is an
1167 (unofficial) patch to parse.y that will modify the grammar to
1168 support this construct. It will not apply with `patch'; you must
1169 modify parse.y by hand. Note that if you apply this, you must
1170 recompile with -DREDIRECTION_HACK. This introduces a large
1171 number of reduce/reduce conflicts into the shell grammar.
1173 F6) Why can't I use vi-mode editing on Red Hat Linux 6.1?
1175 The short answer is that Red Hat screwed up.
1177 The long answer is that they shipped an /etc/inputrc that only works
1178 for emacs mode editing, and then screwed all the vi users by setting
1179 INPUTRC to /etc/inputrc in /etc/profile.
1181 The short fix is to do one of the following: remove or rename
1182 /etc/inputrc, set INPUTRC=~/.inputrc in ~/.bashrc (or .bash_profile,
1183 but make sure you export it if you do), remove the assignment to
1184 INPUTRC from /etc/profile, add
1188 to the beginning of /etc/inputrc, or bracket the key bindings in
1189 /etc/inputrc with these lines
1195 Section G: How can I get bash to do certain common things?
1197 G1) How can I get bash to read and display eight-bit characters?
1199 This is a process requiring several steps.
1201 First, you must ensure that the `physical' data path is a full eight
1202 bits. For xterms, for example, the `vt100' resources `eightBitInput'
1203 and `eightBitOutput' should be set to `true'.
1205 Once you have set up an eight-bit path, you must tell the kernel and
1206 tty driver to leave the eighth bit of characters alone when processing
1207 keyboard input. Use `stty' to do this:
1209 stty cs8 -istrip -parenb
1211 For old BSD-style systems, you can use
1219 Finally, you need to tell readline that you will be inputting and
1220 displaying eight-bit characters. You use readline variables to do
1221 this. These variables can be set in your .inputrc or using the bash
1222 `bind' builtin. Here's an example using `bind':
1224 bash$ bind 'set convert-meta off'
1225 bash$ bind 'set meta-flag on'
1226 bash$ bind 'set output-meta on'
1228 The `set' commands between the single quotes may also be placed
1231 G2) How do I write a function `x' to replace builtin command `x', but
1232 still invoke the command from within the function?
1234 This is why the `command' and `builtin' builtins exist. The
1235 `command' builtin executes the command supplied as its first
1236 argument, skipping over any function defined with that name. The
1237 `builtin' builtin executes the builtin command given as its first
1240 For example, to write a function to replace `cd' that writes the
1241 hostname and current directory to an xterm title bar, use
1242 something like the following:
1246 builtin cd "$@" && xtitle "$HOST: $PWD"
1249 This could also be written using `command' instead of `builtin';
1250 the version above is marginally more efficient.
1252 G3) How can I find the value of a shell variable whose name is the value
1253 of another shell variable?
1255 Versions of Bash newer than Bash-2.0 support this directly. You can use
1259 For example, the following sequence of commands will echo `z':
1265 For sh compatibility, use the `eval' builtin. The important
1266 thing to remember is that `eval' expands the arguments you give
1267 it again, so you need to quote the parts of the arguments that
1268 you want `eval' to act on.
1270 For example, this expression prints the value of the last positional
1273 eval echo \"\$\{$#\}\"
1275 The expansion of the quoted portions of this expression will be
1276 deferred until `eval' runs, while the `$#' will be expanded
1277 before `eval' is executed. In versions of bash later than bash-2.0,
1281 does the same thing.
1283 G4) How can I make the bash `time' reserved word print timing output that
1284 looks like the output from my system's /usr/bin/time?
1286 The bash command timing code looks for a variable `TIMEFORMAT' and
1287 uses its value as a format string to decide how to display the
1290 The value of TIMEFORMAT is a string with `%' escapes expanded in a
1291 fashion similar in spirit to printf(3). The manual page explains
1292 the meanings of the escape sequences in the format string.
1294 If TIMEFORMAT is not set, bash acts as if the following assignment had
1297 TIMEFORMAT=$'\nreal\t%3lR\nuser\t%3lU\nsys\t%3lS'
1299 The POSIX.2 default time format (used by `time -p command') is
1301 TIMEFORMAT=$'real %2R\nuser %2U\nsys %2S'
1303 The BSD /usr/bin/time format can be emulated with:
1305 TIMEFORMAT=$'\t%1R real\t%1U user\t%1S sys'
1307 The System V /usr/bin/time format can be emulated with:
1309 TIMEFORMAT=$'\nreal\t%1R\nuser\t%1U\nsys\t%1S'
1311 The ksh format can be emulated with:
1313 TIMEFORMAT=$'\nreal\t%2lR\nuser\t%2lU\nsys\t%2lS'
1315 G5) How do I get the current directory into my prompt?
1317 Bash provides a number of backslash-escape sequences which are expanded
1318 when the prompt string (PS1 or PS2) is displayed. The full list is in
1321 The \w expansion gives the full pathname of the current directory, with
1322 a tilde (`~') substituted for the current value of $HOME. The \W
1323 expansion gives the basename of the current directory. To put the full
1324 pathname of the current directory into the path without any tilde
1325 subsitution, use $PWD. Here are some examples:
1327 PS1='\w$ ' # current directory with tilde
1328 PS1='\W$ ' # basename of current directory
1329 PS1='$PWD$ ' # full pathname of current directory
1331 The single quotes are important in the final example to prevent $PWD from
1332 being expanded when the assignment to PS1 is performed.
1334 G6) How can I rename "*.foo" to "*.bar"?
1336 Use the pattern removal functionality described in D3. The following `for'
1337 loop will do the trick:
1343 G7) How can I translate a filename from uppercase to lowercase?
1345 The script examples/functions/lowercase, originally written by John DuBois,
1346 will do the trick. The converse is left as an exercise.
1348 G8) How can I write a filename expansion (globbing) pattern that will match
1349 all files in the current directory except "." and ".."?
1351 You must have set the `extglob' shell option using `shopt -s extglob' to use
1356 A solution that works without extended globbing is given in the Unix Shell
1357 FAQ, posted periodically to comp.unix.shell.
1359 Section H: Where do I go from here?
1361 H1) How do I report bugs in bash, and where should I look for fixes and
1364 Use the `bashbug' script to report bugs. It is built and
1365 installed at the same time as bash. It provides a standard
1366 template for reporting a problem and automatically includes
1367 information about your configuration and build environment.
1369 `bashbug' sends its reports to bug-bash@gnu.org, which
1370 is a large mailing list gatewayed to the usenet newsgroup gnu.bash.bug.
1372 Bug fixes, answers to questions, and announcements of new releases
1373 are all posted to gnu.bash.bug. Discussions concerning bash features
1374 and problems also take place there.
1376 To reach the bash maintainers directly, send mail to
1377 bash-maintainers@gnu.org.
1379 H2) What kind of bash documentation is there?
1381 First, look in the doc directory in the bash distribution. It should
1382 contain at least the following files:
1384 bash.1 an extensive, thorough Unix-style manual page
1385 builtins.1 a manual page covering just bash builtin commands
1386 bashref.texi a reference manual in GNU tex`info format
1387 bashref.info an info version of the reference manual
1389 article.ms text of an article written for The Linux Journal
1390 readline.3 a man page describing readline
1392 Postscript, HTML, and ASCII files created from the above source are
1393 available in the documentation distribution.
1395 There is additional documentation available for anonymous FTP from host
1396 ftp.cwru.edu in the `pub/bash' directory.
1398 Cameron Newham and Bill Rosenblatt have written a book on bash, published
1399 by O'Reilly and Associates. The book is based on Bill Rosenblatt's Korn
1400 Shell book. The title is ``Learning the Bash Shell'', and the ISBN number
1401 is 1-56592-147-X. Look for it in fine bookstores near you. This book
1402 covers bash-1.14, but has an appendix describing some of the new features
1405 A second edition of this book is available, published in January, 1998.
1406 The ISBN number is 1-56592-347-2. Look for it in the same fine bookstores
1409 H3) What's coming in future versions?
1411 These are features I plan to include in a future version of bash.
1413 a bash debugger (a minimally-tested version is included with bash-2.04)
1416 H4) What's on the bash `wish list' for future versions?
1418 These are features that may or may not appear in a future version of bash.
1420 breaking some of the shell functionality into embeddable libraries
1421 a module system like zsh's, using dynamic loading like builtins
1422 better internationalization using GNU `gettext'
1423 an option to use external files for the long `help' text
1424 date-stamped command history
1425 a bash programmer's guide with a chapter on creating loadable builtins
1426 a better loadable interface to perl with access to the shell builtins and
1427 variables (contributions gratefully accepted)
1429 H5) When will the next release appear?
1431 The next version will appear sometime in 2000 or 2001. Never make
1435 This document is Copyright 1995-2000 by Chester Ramey.
1437 Permission is hereby granted, without written agreement and
1438 without license or royalty fees, to use, copy, and distribute
1439 this document for any purpose, provided that the above copyright
1440 notice appears in all copies of this document and that the
1441 contents of this document remain unaltered.