So far in this book, you've been typing in commands (or perhaps combining commands), pressing , then waiting for Unix to execute the command(s) you specified...and typing in commands, pressing , and waiting for Unix... and typing in commands.... You get the idea, and you probably have tired fingers by now.
Using shell scripts, you can create a series of commands, save them as a single file, and then execute them any time you wantwithout having to re-create the commands or do all that tedious typing over and over again. For example, suppose you want to do a complex search-and-replace on all the .htm files in your home directory. With a shell script, you can take the time to structure the commands just one time, save the commands as a single file, and then apply it to any directory at any time. You do the hard work one time, and then reuse the script any time you need to.
In this book we'll discuss creating scripts using the sh (Bourne) shell. Scripts can be written with any shelland zsh and bash in particular are quite good for scripting.
In this chapter, we'll show you how to get started creating and using shell scripts. We won't go into the gory details about scripting (thank goodness, right?!), but we will give you enough information to create your own scripts and apply them to your particular uses.