Chapter 12. The Bash Shell

WHAT YOU WILL LEARN IN THIS CHAPTER:

  • How to configure and use Bash interactively and for running scripts

  • How to use the Terminal application for accessing the command line

  • The most important Unix commands and where to find information about commands

  • Some of the commands that are available only on Mac OS X

  • Basic shell programming

At the heart of every Mac OS X system is a Unix core. If you don't look for it, you won't see it, but it's there. As with all Unix systems, Mac OS X relies heavily on shell scripts. When you log into your account at startup — whatever you happen to be doing on Mac OS X — chances are good that a shell script is involved in some way.

After reading Chapter 11, you know that scripts are simple programs that string together Unix commands to perform a task. Scripts are run by a program called a shell, which interprets one line of code at a time. On Mac OS X, the default shell is called Bash, which is a powerful shell that can be used interactively or to run scripts. Upon completing this chapter, you should have a good basis for working with the Bash shell.

GETTING STARTED

Before you can start interacting with the operating system via the Terminal application or writing your own shell scripts, some preliminaries need to be taken care of. First, you need to know what a command-line interface (CLI) is and the different ways in which it can be used. You need to have an application that can access the CLI and a way to edit scripts and other text files. ...

Get Beginning, Mac OS® X Snow Leopard™ Programming 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.