MTC logo MTC logo Midlands Technical College
Prospective StudentsEnrolled StudentsFaculty & StaffCommunity Partners
About
Academics
Continuing Education
Distance Learning
Student Forms
Library
Class Schedule
News & Updates
Calendar
Directory
Site Map
Ask MTC
MTC Jobs Bookstore
Home
navigation
 
Search

 

About MTC Academics Continuing Education Distance Learning Student Forms Library Class Schedule News & Updates Calendar Directory Site Map Ask MTC MTC Jobs Bookstore Home


CPT 247


Quick Reference

Exercise

Shellscript1

 

Editor command summary.

Opening, Writing, and Closing Files

    vi file        open file named file (UNIX shell command)

    :w            write changes into default file

    :w file        write changes into file named file

    :q            quit vi

    :wq        write changes into file and quit vi

    :q!        quit without writing changes into file

Inserting Text (vi command mode)

    a    add text to the right of the current cursor location

    i    insert text to the left of the curosr

    O    Open up a new line above the current line

    o    open up a new line below the current line

    R    Replace (type over) text

    ESC    return to command mode

Correcting Mistakes (vi command mode)

    x        delete one character

    dd        delete entire line

    ndd        delete n lines

    u            "undo" most recent change

    U            "Undo" all changes on current line

Check Spelling (UNIX shell command)

    spell file        list misspelled words found in file

Searching (vi command mode)

    /word        search forward for the first occurrence of word

    /                continue search for the next occurrence of word

    ?word        search backward for the first occurrence of word

    ?                continue search backward for the next occurrence of word

Setting Line Number (vi command mode)

    :set nu        set line numbers on the screen

    :set nonu    remove line numbers

Yanking and Putting (vi command mode) 

    "knyy        yank (copy) n lines into buffer "k

    "kp            put the contents of buffer "k below the current line

Substituting Text Globally (vi command mode)

     %s/old/new/g      replace old by new everywhere in the file

Editing Another File (vi command mode)

    :e file         edit file

Selecting an Editor for Command-Line Editing (UNIX shell commands)

VISUAL=vi        select vi (for ksh)

set -o vi                select vi (for bash)