Chapter 8. Shaking Hands with Your Shell


IN THIS CHAPTER

  • The Power of the Command Line

  • Writing a Shell Script: The Basics

  • Scripting in bash

  • Variables in Shell Scripts

  • Positional Parameters

  • Built-In Variables

"In the beginning was the command line," sayeth Neal Stephenson in his wonderful essay on the history of computer operating systems. And so it is true. The easiest and fastest way to get things done in Linux is directly from the command line, called the shell. Why a shell? If the heart of the operating system is the kernel of the nut, clearly you have to crack the shell to get at it.

The point-and-click graphical interface is easy, once you've learned it. Yet there is so much power behind a couple of keystrokes in the shell that it's sometimes hard to think of an easier way to do things. The big difference is the learning curve. In the GUI, after you've figured out how a mouse works, you're well on your way to getting work done. As opposed to this, that cold empty shell prompt gives you no advice on what to do with it.

No matter how expert you are with the graphical interface, there may be times when you have to rescue a system, and a shell prompt is all you have to work with. It's important to know at least a few commands to get things going. Throughout this book, you'll find plenty of ideas on using your shell to quickly get computing tasks done.

In this chapter, we will focus on understanding the shell as a programming language. Most of the shells included in SUSE Linux allow you to string commands together in an editor and save them as a script. Knowing the shell's syntax, you can define variables, assign values, create functions, and evaluate different results most everything a "real" programming language such as C, Java, or C++ can do. Many of the standard shell commands are really just shell scripts. Perhaps your script will one day find itself in common usage, too.



SUSE Linux 10 Unleashed
SUSE Linux 10.0 Unleashed
ISBN: 0672327260
EAN: 2147483647
Year: 2003
Pages: 332

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net