Appendix B. Examples Included with bash

The bash tarball includes a lot of material that is well worth exploring (after you’ve finished reading this book, of course). It includes sample code and examples, scripts, functions, and startup files. The easiest way to access this material is via our up-to-date list with hyperlinks, but we’re including this appendix to provide a taste of what you’ll find since few people actually access the tarball or build from source anymore.

bash Documentation and Examples

The startup-files directory provides many examples of what you can put in your own startup files. In particular, bash_aliases has many useful aliases. Bear in mind that if you copy these files wholesale, you’ll have to edit them for your system because many of the paths will be different. Refer to Chapter 16 for further information on changing these files to suit your needs.

The functions directory contains many function definitions that you might find useful. Among them are:

basename

The basename utility, missing from some systems.

dirfuncs

Directory manipulation facilities.

dirname

The dirname utility, missing from some systems.

whatis

An implementation of the Tenth Edition Bourne shell whatis builtin.

whence

An almost exact clone of the Korn shell whence builtin.

If you come from a Korn shell background, you may find kshenv especially helpful. This contains function definitions for some common Korn facilities such as whence, print, and the two-parameter cd builtins. ...

Get bash Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.