Shell Scripting Recipes: A Problem-Solution Approach
by Chris F.A. Johnson
448 Pages
POSIX shell scripts offer a means for creating powerful and portable
applications. When coupled with utilities such as grep, sed, and the
AWK programming language, the shell is more than adequate for
resolving a wide range of programming tasks. I wrote this book to
demonstrate these capabilities and help you to learn shell scripting
by providing hundreds of examples.
The
opening chapter sets the stage for this
collection, introducing many Unix shell features and helping
familiarize you with the syntax in many of the examples. The following
chapters present scripts and shell functions ranging from one-liners
to multipage programs. These scripts and functions convert DOS-based
text files to Unix and vice versa, maintain financial ledgers (which
can be easily imported to a spreadsheet program), extract information
from web pages, and more. To facilitate code reuse, the book offers
numerous function libraries that you can use to build even more
programs quickly.
Some scripts in this book are taken from the hundreds I've written
over the past 15 years, while others were written specifically for
this book. I carefully selected each not only to demonstrate the
breadth of problems that can be solved with shell scripts, but also to
illustrate as many scripting techniques as possible.*
I hope this book will help you solve the many problems
illustrated by these scripts, and also encourage and help you to write
your own.
| Ch. | Title |
| 1 | The POSIX Shell and Command-Line Utilities |
| 2 | Playing with Files: Viewing, Manipulating, and Editing Text Files |
| 3 | String briefs |
| 4 | What's in a Word? |
| 5 | Scripting by Numbers |
| 6 | Loose Names Sink Scripts: Bringing Sanity to Filenames
The Naming of Files is a serious matter,
This isn't just one of your Usenet flames;
You may think at first it doesn't much matter
But I tell you, a file should have a SENSIBLE NAME.
(with apologies to T. S. Eliot)
|
| 7 | Treading a Righteous PATH |
| 8 | The Dating Game (Sample chapter PDF or HTML)
|
| 9 | Good Housekeeping: Monitoring and Tidying Up File Systems |
| 10 | POP Goes the E-Mail |
| 11 | PostScript: More Than an Afterthought
This crossword grid was created by the ps-grid script in Chapter 11.
This puzzle's source file (in AcrossLite text format) can also be found in that chapter.
ACROSS
1 The woman will, for outer covering (5)
4 Host reformatted after a thousand bugs (5)
5 Collection of data by a random beam (5)
DOWN
1 Frodo's companion has degree in file services (5)
2 Go in to get key for execution (5)
3 In a real OS, symbolic type of compression (5)
|
|
| 12 | Screen Manipulation: |
| 13 | Backing Up the Drive |
| 14 | Aging, archiving and deleting files |
| 15 | Covering All Your Databases |
| 16 | Home on the Web |
| 17 | Taking Care of Business |
| 18 | Random Acts of Scripting
"The generation of random numbers is too important
to be left to chance."
Robert R. Coveyou, Oak Ridge National Laboratory
|
| 19 | A Smorgasbord of Scripts |
| 20 | Script development management |