O'Reilly logo

bash Cookbook by Cameron Newham, JP Vossen, Carl Albing

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix B. Examples Included with bash

The bash tarball archive includes an examples directory that is well worth exploring (after you've finished reading this book, of course). It includes sample code, scripts, functions, and startup files.

Startup-Files Directory 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 built-in

whence

An almost exact clone of the Korn shell whence built-in

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 built-ins.

The scripts directory contains many examples of bash scripts. The two largest scripts are examples of the complex things you can do with shell scripts. The first is a (rather amusing) adventure game interpreter and the second is a C shell interpreter. The other ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required