Shell Variables   «Prev 

UNIX is case sensitive within all contexts

vi is case-sensitive:

Remember that UNIX is case sensitive. You can cause yourself all sorts of problems by using variable names with mixed case and then forgetting how you have defined those variables. Shell scripts do not perform any checking on variables like regular programming languages do, so it is up to you to be consistent in how you use variables so that your scripts are easy to debug.

vi commands

The keystroke commands in vi are case-sensitive. The actions of the uppercase letter (such as A) and the lowercase letter (such as a) are slightly different. To change from Insert Mode to Command Mode, press the Esc key.
To change from Command Mode to Last Line Mode, type : (or SHIFT-: in some UNIX operating systems). When that is done, characters are echoed or shown on the last line on the screen.
To terminate Last Line Mode, type Enter after commands.

What is the shell?

The shell is a special program used as an interface between the user and the heart of the UNIX operating system, a program called the kernel, as shown in Figure 1.1. The kernel is loaded into memory at boot time and manages the system until shutdown. It creates and controls processes, and manages memory, file systems, communications, and so forth. All other programs, including shell programs, reside out on the disk. The kernel loads those programs into memory, executes them, and cleans up the system when they terminate. The shell is a utility program that starts up when you log on. It allows users to interact with the kernel by interpreting commands that are typed either at the command line or in a script file.

How you interact with the shell
How you interact with the shell

Interactive Shell

When you log on, an interactive shell starts up and prompts you for input. After you type a command, it is the responsibility of the shell to (a) parse the command line; (b) handle wildcards, redirection, pipes, and job control; and (c) search for the command, and if found, execute that command. When you first learn UNIX, you spend most of your time executing commands from the prompt. You use the shell interactively.
If you type the same set of commands on a regular basis, you may want to automate those tasks. This can be done by putting the commands in a file, called a script file, and then executing the file. A shell script is much like a batch file: It is a list of UNIX commands typed into a file, and then the file is executed. More sophisticated scripts contain programming constructs for making decisions, looping, file testing, and so forth. Writing scripts not only requires learning programming constructs and techniques, but assumes that you have a good understanding of UNIX utilities and how they work. There are some utilities, such as
  1. grep,
  2. sed, and
  3. awk
that are extremely powerful tools used in scripts for the manipulation of command output and files. After you have become familiar with these tools and the programming constructs for your particular shell, you will be ready to start writing useful scripts. When executing commands from within a script, you are using the shell as a programming language.