DistributedNetworks DistributedNetworks


Unix Shell Scripts   «Prev 

UNIX Text Editors

Many text editors are included with most UNIX operating systems. Some are popular, others are specialized and may not be of much use. If you are already familiar with another text editor, feel free to use that editor to create shell scripts during this course.
Some of the popular UNIX text editors include the following:
  1. emacs, a very powerful text editor with hundreds of configuration options and keyboard commands. A graphical version of emacs, called xemacs, provides menus to access basic editing features.
  2. pico, a simple editor with on-screen keyboard commands to make it easy for new users to create and edit text files.
  3. ed, an old-fashioned editor that works on a single line of a file at a time.
  4. joe, an easy to use editor with basic functionality

Of the editors in the above list, vi and nano are available for Red hat and Ubuntu Linux. If you are working on a UNIX system at your site, you may have one or move of these text editors, in addition to a graphical text editor. Each version of UNIX provides a basic text editor from its graphical menus. Consult your documentation or system administrator for assistance in located a graphical editor on your UNIX system.

What Are Shell Scripts?

A shell script is a text file that contains one or more commands. This seems pretty simple after all this buildup, but that is all a script really is. The power of shell scripts, however, lies not in the simplicity of the concept, but in what you can do with these files. In a shell script, the shell assumes each line of the text file holds a separate command. These commands appear for the most part as if you had typed them in at a shell window. (There are a few differences, covered in the chapters to follow.) For example, this code shows two commands:
df -k
ls

The following Try It Out shows you how to make these two commands into a script and run it. You will see a number of very short examples that should provide a quick overview to scripting.