DispersedNet
SiteMap
Unix Concepts
Shell Programming
Shell Scripting
Unix Questions
Unix Shell Scripts
«Prev
Next»
Shell Programming
Shell Programming
Unix Shell Available
Determining Unix Shell
Shell Scripts Unix
Interpreted Compiled Programs
Understanding Scripting Options
Cmpiled Programs
Shell Components
Shell Script Macro
Built in Components
Input Output Tools
Shell Script Tests
Script Variables
shell-script-control-structures
Regex Define Patterns
Shell Program Components
Writing First Script
Interactive Shell Script
Defining Script File
Using Text Editor
Read Input Command
Including Comments Scripts
Setting File Permissions
Running Command Line
Working With Variables
Command Line Arguments
Using Positional Variables
Predefined System Variables
System Variables
Environment Variables
Syntax Affects Interpretation
Using Strings Variables
Using Numbers-inVariables
Performing Math Variables
Using Array Variables
Scripts Variable Summary
Designing Scripts
Script Objective
Script Flow
loop Tests
Checking Commands
error Trapping
Making Script Portable
Documenting Script
Designing Shell Scripts
Using Text Editor - Exercise
Practice using the vi Editor
Objective:
Use vi to create and edit a script file
Exercise Scoring
This exercise is worth 3 points.
Background/overview
You should have an account set up on the DispersedNet Labs server or on a UNIX server at your site. Log in to this account so that you see a UNIX command line prompt.
Instructions
Log in to your UNIX account so that you are working at a command prompt.
Start vi with a filename for the script you will create. Let’s make the filename for your script in this exercise “welcome.” So, type in the following line:
% vi welcome
You see a blank screen except for a tilde character on each line. This character indicates a line beyond the end of the file (hence, the file is empty if you see only tildes). When you start vi, you always begin in command mode.
Press
i
to change to Insert mode. The word
INSERT
appears at the bottom of your screen.
Enter the first line of your script and press Enter. The first line of your script should be:
#!/bin/sh
Press Esc to return to command mode. The word
INSERT
disappears.
Press colon, w, q, Enter to save your file and exit from vi.
View the contents of the file you just created by typing the following line:
% cat welcome
Hints
You must start vi from a directory where you have permission to create new files, such as your home directory. Ask your system administrator for assistance if you cannot create a new file in your home directory. If you are using the DispersedNet UNIX lab, you can create files in the directory that you begin working in (your home directory).