Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

UBUNTU / TERMINAL Vi editing. Open your terminal and connect to snowball server.

ID: 3786480 • Letter: U

Question

UBUNTU / TERMINAL

Vi editing.

Open your terminal and connect to snowball server. Change your directory to your home directory (cd ~ ), and then create a new directory named as “PC2” (mkdir PC3). After that, go to directory PC2 (cd PC3) and please download a test file by the following command (internet access required):

cp /home/local/GSUAD/ylong4/public/CSC_Course.txt CSC_Course.txt

Be sure it succeeds using “ls” to see the file name “CSC_Course.txt” listed.

Please write the commands you will issue to complete the following tasks and answering corresponding questions step by step.

1) Use vi to open “CSC_Course.txt”.

2) Display line number.

3) Move the cursor to line 181 col. 1 (the first character in line 181). What do you see in this line?

4) Search the word "OPERATING". Which line is this string located? (Please just write down the line number) Delete the word "OPERATING".

5) Delete the current line.

6) Substitute all "CSC" with "Computer Science" in the first 30 lines.

7) Copy three lines between line 143 and 145 to the beginning of the file.

8) Delete three lines between line 143 and 145.

9) Describe how to enter the text mode and key in “ End: All CSc Courses " as the last line of the file.

10)Switch back to command mode.

11)Save the file and quit vi.

Explanation / Answer

[1] vi CSC_Course.txt
[2] :set number
[3] vi +181 CSC_Course.txt
[4] grep -n -F OPERATING CSC_Course.txt
[5] sed 's/OPERATING //g' CSC_Course.txt
[6] dd
[7]
1.Press the ESC key to be sure you are in vi Command mode.
2.Place the cursor on the first line of the text you wish to copy.
3.Type 3yy to copy the 12 lines.
4.Move the cursor to the place where you wish to insert the copied lines. lines after the current line on which the cursor is resting or type P to insert the copied line before the current line.

[8] vi +143 CSC_Course.txt
     3dd
[9] press i key
     Move the cursor to end of file
      then type End: All CSc Courses
[10] Esc
[11] :wq