Table Of ContentHello, World! Your First Shell Program.- Input, Output, and Throughput.- Looping and Branching.- Command-Line Parsing and Expansion.- Parameters and Variables.- Shell Functions.- String Manipulation.- File Operations and Commands.- Reserved Words and Builtin Commands.- Writing Bug-Free Scripts and Debugging the Rest.- Programming for the Command Line.- Runtime Configuration.- Data Processing.- Scripting the Screen.- Entry-Level Programming.
SynopsisThe bash shell is a complete programming language, notmerely a glue to combine external Linux commands. Bytaking full advantage of shell internals, shell programscan perform as snappily as utilities written in C orother compiled languages. And you will see how, withoutassuming Unix lore, you can write professional bash 4.0programs ......, Introduction Although most users think of the shell as an interactive command interpreter, it is really a programming language in which each statement runs a command. Because it must satisfy both the interactive and programming aspects of command execution, it is a strange language, shaped as much by history as by design. Brian Kernighan and Rob Pike, The UNIX Programming Environment, Prentice-Hall, 1984 The shell is a programming language. Don't let anyone tell you otherwise. The shell is not just glue that sticks bits together. The shell is a lot more than a tool that runs other tools. The shell is a complete programming language! When a Linux user asked me about membership databases, I asked him what he really needed. He wanted to store names and addresses for a couple of hundred members and print mailing labels for each of them. I recommended using a text editor to store the information in a text file, and I provided a shell script to create the labels in PostScript. (The script, ps-labels, appeared in my first book, Shell Scripting Recipes: A Problem-Solution Approach. ) When the SWEN worm was dumping hundreds of megabytes of junk into my mailbox every few minutes, I wrote a shell script to filter them out on the mail server and download the remaining mail to my home computer. That script has been doing its job for several years., Introduction Although most users think of the shell as an interactive command interpreter, it is really a programming language in which each statement runs a command. Because it must satisfy both the interactive and programming aspects of command execution, it is a strange language, shaped as much by history as by design. Brian Kernighan and Rob Pike, The UNIX Programming Environment, Prentice-Hall, 1984 The shell is a programming language. Don't let anyone tell you otherwise. The shell is not just glue that sticks bits together. The shell is a lot more than a tool that runs other tools. The shell is a complete programming language When a Linux user asked me about membership databases, I asked him what he really needed. He wanted to store names and addresses for a couple of hundred members and print mailing labels for each of them. I recommended using a text editor to store the information in a text file, and I provided a shell script to create the labels in PostScript. (The script, ps-labels, appeared in my first book, Shell Scripting Recipes: A Problem-Solution Approach. ) When the SWEN worm was dumping hundreds of megabytes of junk into my mailbox every few minutes, I wrote a shell script to filter them out on the mail server and download the remaining mail to my home computer. That script has been doing its job for several years., The bash shell is a complete programming language, not merely a glue to combine external Linux commands. By taking full advantage of shell internals, shell programs can perform as snappily as utilities written in C or other compiled languages. And you will see how, without assuming Unix lore, you can write professional bash 4.0 programs through standard programming techniques. Complete bash coverage Teaches bash as a programming language Helps you master bash 4.0 features