Shell scripts are text files. They cannot contain any special formatting or font information. Shell scripts can be created in any word
processor or text editor, as long as they are saved as plain text files.
Some text editors can color code shell scripts, highlighting comments, commands, and variables. This information is to help you understand
the script. The formatting and colors are not saved as part of the text file.
The most well-known text editor on modern UNIX systems is the vi editor. UNIX systems
have other editors
, including graphical editors that are easy to use.
But because vi is available on all UNIX systems, we will use it as the basis for writing our shell scripts. The information presented in this lesson should be a review for you.
It is not easy to use vi until you have mastered a few of its fundamentals.
The vi text editor has several modes. The two main modes you will use are command mode and insert mode. In command mode, characters that you
enter are interpreted as commands; in insert mode, characters that you type are entered as part of your document. After inserting text (or if
you are not sure what mode you are in), you can always change to command mode by pressing the Esc key, which toggles between the two modes.
Click on the Exercise link below to practice using vi in the UNIX Lab.
Unix Text Editor - Exercise
The next lesson introduces a command to write information to the screen from a script.