1. Trang chủ
  2. » Công Nghệ Thông Tin

Sun Fundamentals of Solaris 7 Student Guide With Instructor Notes phần 6 potx

68 271 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 68
Dung lượng 340,66 KB

Nội dung

9 9-8 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Positioning Commands The following pages list the vi editor’s editing and positioning commands, which are used to make changes. The vi editor is case sensitive, so use the specified case when using the editing and positioning commands. The Table 9-3 shows the key sequences for character movement:. Table 9-3 Key Sequences Command Meaning h, ←, or Back Space Move left one character j or ↓ Move down one line k or ↑ Move up one line l,→, or Space bar Move right (forward) one character w Move forward one word (including punctuation) W Move forward one word (past punctuation) b Move back one word (including punctuation) B Move back one word (past punctuation) e Move to end of current word $ Move to end of line 0 (zero) or ^ Move to beginning of line Return Move down to beginning of next line H Move to top of screen M Move to middle of screen L Move to bottom of screen Control-f Page forward one screen Control-d Scroll down one-half screen Control-b Page back one screen Control-u Scroll up one-half screen 9 Using the vi Editor 9-9 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Editing Commands Deleting Text To delete text, use the following options: Table 9-4 Text Deletion Commands Command Meaning x (lowercase) Delete character at the cursor X (uppercase) Delete character to the left of the cursor dw Delete word (or part of word to right of cursor) 3dw Delete three words dd Delete line containing the cursor 3dd Delete three lines D Delete line to right of cursor (from cursor position to the end of the line) dG Delete to end of file d1G Delete from beginning of file to cursor :5,10d Delete lines 5 through 10 9 9-10 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Editing Commands Undoing, Repeating, and Changing Text Commands To change text or to cancel or repeat edit functions, use the following commands. Many of these commands change you to Insert mode until you press Escape. Table 9-5 Editing Commands Command Meaning cw Change word (or part of word) at the cursor location to the end of the word 3cw Change three words R Overwrite or replace characters on line C Change from cursor to end of line s Substitute string for character(s) r Replace character at cursor with one other character i (Return) Break line J Join current line and line below xp Transpose character at cursor and character to the right ~ Change case of letter (upper or lower) at cursor u Undo previous command U Undo all changes to current line :u Undo previous last-line command 9 Using the vi Editor 9-11 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Editing Commands Copying and Pasting Text To copy and paste text, use the following options: Note – Both delete and yank write to a buffer. When yanking, deleting, and pasting, the put commands insert the text differently depending on whether you are pasting a word(s) or a line(s). Table 9-6 Copy and Paste Commands Command Meaning yy Yank a copy of line Y Yank a copy of line p Put yanked or deleted line below current line P Put yanked or deleted line above current line :1,3 co 5 Copy lines 1 through 3 and put after line 5 :4,6 m 8 Move lines 4 through 6 to line 8 (line 6 becomes line 8; line 5 becomes line 7, and line 4 becomes line 6) 9 9-12 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Editing Commands Saving and Quitting Files To save and quit a file, use the following options: Table 9-7 Save and Quit Commands Command Meaning :w Save changes (write buffer) :w new_filename Write buffer to new_filename :wq Save changes and quit vi ZZ Save changes and quit vi :q! Quit without saving changes :wq! Save changes and quit vi (The ! will override read only permissions if you are the owner of the file.) 9 Using the vi Editor 9-13 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Advanced Editing Options The vi editor includes options for customizing your edit sessions, such as: ● Displaying line numbers ● Displaying invisible characters such as tab and end-of-line characters The set command is used from last-line mode to control these options. These options can also be placed in a file the user creates in their home directory called .exrc. The set options are placed in this file, without the preceding colon, one command to a line. Once the .exrc file exists, it is read by the system each time a vi session is opened. Table 9-8 Edit Session Customization Commands Command Meaning :set nu Show line numbers :set nonu Hide line numbers :set ic Instruct searches to ignore case :set noic Instruct searches to be case sensitive :set list Display invisible characters such as tab and end-of-line :set nolist Turn off the display of invisible characters :set showmode Display current mode of operation :set noshowmode Turn off mode display :set Display all vi variables set :set all Display all possible vi variables and their current settings 9 9-14 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Advanced Editing Options To find a line or to search and replace and do advanced editing, use the following options: To clear the screen or insert files, use the following options: To search and replace text, use the following options: Table 9-9 Advanced Editing/Search Commands Command Meaning G Go to last line of file 1G Go to first line of file :21 Go to line 21 21G Go to line 21 Table 9-10 Clearing/Insertion Commands Command Meaning Control-L Clear (refresh) scrambled screen :r filename Insert (read) file at line after cursor :34 r filename Insert file after line 34 Table 9-11 Search and Replace Commands Command Meaning / string Search forward for string ? string Search backward for string n Find next occurrence of string N Find previous occurrence of string :%s/ old / new /g Search and replace globally 9 Using the vi Editor 9-15 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Creating and Saving a File To create a file using the vi editor: 1. Type vi filename to create the file. 2. Type i to insert text. 3. Press the Escape key to change to command mode. 4. Type :wq to write the file and exit vi. Note – The Escape key always puts you in command mode. Use the Escape key if you are not sure what mode you are in. If you press the Escape key while you are in command mode, the workstation beeps as a reminder that you are already in command mode. 9 9-16 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using the vi Editor Exercise objective – In this exercise you will practice creating and editing using vi. Tasks Complete the following step: 1. In your home directory there should be a file called tutor.vi. Make sure that you are currently in your home directory, then open this file with the command: $ vi tutor.vi this will open up a vi tutorial. Complete the lessons outlined in this tutorial. 9 Using the vi Editor 9-17 Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1999, Revision D Exercise: Using the vi Editor Exercise Summary Discussion – Take a few minutes to discuss what experiences, issues, or discoveries you had during the lab exercises. ✓ Manage the discussion here based on the time allowed for this module, which was given in the “About This Course” module. If you find you do not have time to spend on discussion, then just highlight the key concepts students should have learned from the lab exercise. ● Experiences ✓ Ask students what their overall experiences with this exercise have been. You might want to go over any trouble spots or especially confusing areas at this time. ● Interpretations ✓ Ask students to interpret what they observed during any aspects of this exercise. ● Conclusions ✓ Have students articulate any conclusions they reached as a result of this exercise experience. ● Applications ✓ Explore with students how they might apply what they learned in this exercise to situations at their workplace. [...]... references can provide additional details on the topics discussed in this module: q q Solaris Advanced User’s Guide to System and Network Tasks, Chapters 1 and 3, Part Number 801-4415-10 q 10-2 Solaris User’s Guide, Part Number 802 -64 99 Man pages for sh(1), ksh(1), and csh(1) Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D... HOME=/home/guest HZ=100 IFS= LANG=C LINENO=1 LOGNAME=guest MAIL=/var/mail/guest MAILCHECK =60 0 MANPATH=/usr/openwin/share/man:/usr/man NOSUNVIEW=0 OPENWINHOME=/usr/openwin PATH=/usr/openwin/bin:/usr/bin: PPID=8 67 PS1=$ PWD=/home/guest RANDOM=4188 SHELL=/bin/ksh TERM =sun- cmd TZ=PST8PDT USER=guest 10-8 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999,... HELPPATH=/usr/openwin/lib/locale:/usr/openwin/lib/help HZ=100 NOSUNVIEW=0 PATH=/usr/openwin/bin:/usr/bin: WINDOW_TERMIOS= OPENWINHOME=/usr/openwin LOGNAME=user1 MAIL=/var/mail/user1 TERMCAP =sun- cmd:te=\E[>4h:ti=\E[>4l:tc =sun: DISPLAY=:0.0 SHELL=/bin/ksh HOME=/home/user1 TERM =sun- cmd PWD=/opt TZ=US/Pacific ENV=/export/home/user1/.kshrc XINITRC=/usr/openwin/lib/Xinitrc 10-12 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All... the value of NAME this time? _ 5 List all of the environment variables Is NAME an environmental variable? _ 6 Determine how your current PATH variable is set 7 Add the /usr/ucb directory to your path and export the variable 10- 16 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999,... three modes of vi and identify the commands that belong to each mode Perform search and replace functions within vi Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 9 Think Beyond Under what conditions might it be necessary for you to use the vi editor in your work environment? Using the vi Editor 9-19 Copyright 1999 Sun Microsystems,... exercise experience q  Interpretations Ask students to interpret what they observed during any aspects of this exercise q  Experiences Applications Explore with students how they might apply what they learned in this exercise to situations at their workplace Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 10 Exercise: Using... system? 10-22 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D Initialization Files 11 Objectives Upon completion of this module, you should be able to: q Name the different initialization files for the Bourne, Korn, and C shells q Identify the initialization file used by the Common Desktop Environment q Define the purpose of initialization... preceding a variable name enables the system to use the value of the variable and not the name of the variable In the above example, the echo command with $DT displays the value of DT to the screen Since this is a local variable, if a new subshell is opened, the variable DT is not available Bourne and Korn Shell Variables 10 -7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services... found in your PATH statement, the whereis command searches all of the directories on the system that usually have executable files located in them The whereis command will display all directories where the command is located, including the appropriate man page Command Format whereis filename 10-14 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August... based on a name and value selected by the user, while the unset command removes the variable from the current shell and subshells: Command Format VARIABLE=value unset VARIABLE 10 -6 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems, Inc All Rights Reserved Enterprise Services August 1999, Revision D 10 Shell Variables Local Shell Variables Setting a Local Variable $ DT=/usr/dict $ echo $DT /usr/dict . after line 5 :4 ,6 m 8 Move lines 4 through 6 to line 8 (line 6 becomes line 8; line 5 becomes line 7, and line 4 becomes line 6) 9 9-12 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems,. position to the end of the line) dG Delete to end of file d1G Delete from beginning of file to cursor :5,10d Delete lines 5 through 10 9 9-10 Fundamentals of Solaris 7 Copyright 1999 Sun Microsystems,. end of current word $ Move to end of line 0 (zero) or ^ Move to beginning of line Return Move down to beginning of next line H Move to top of screen M Move to middle of screen L Move to bottom of

Ngày đăng: 13/08/2014, 02:23