Linux Shell Programming Technology
Linux has some features to make your life a bit easier. Any time you have a repetitive task that involves entering Linux commands or changing the contents of a file, you should think about automating it with a program. If you've ever written a word processor macro or a spreadsheet formula, you're a programmer. By taking advantage of Linux's built-in programming features, you can automate repetitive tasks and build simple interactive applications without a degree in computer science. This section covers basic shell script programming and introduces you to other, more powerful programming tools available in Linux, such as Perl and the C and C++ programming languages.
Basic Shell Programming
The Bash shell is your main port of entry to Linux, since the shell interprets everything you enter on the command line before passing it along to the operating system for execution. But in addition to providing the niceties of command resolution, wildcard handling, and piping, Bash has its own powerful built-in programming language.
A shell script is a program written for Bash. The simplest shell script is a sequence of Linux commands, but when you add the power of variables and flow control, you can do a lot more with it. Shell scripts are similar to DOS batch files (those files that end in .bat), but shell scripts are more powerful and actually easier to create.
Shell scripts are interpreted, which means that the shell reads each line and acts on it immediately. This process differs from that of a formal programming language like C or C++, where the program is compiled and optimized for faster execution. So there's a tradeoff--it's easier to create quick little shell scripts, but if the task at hand requires serious number crunching or complicated logic, a compiled language is better.