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 scripts include examples of precedence rules, a scrolling text display, a “spinning wheel” progress display, and how to prompt the user for a particular type of answer.

Not only are the script and function examples useful for including in your ...

Get bash Cookbook 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.