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

Linux Using the vi editor: 1.- Create a document named doc01.txt with 10 lines e

ID: 3591376 • Letter: L

Question

Linux

Using the vi editor: 1.- Create a document named doc01.txt with 10 lines each containing the sentence "Yesterday was the day." Write the sentence only one time. 2.- Save the file doc01.txt and exit vi. 3.- Create a document named doc02.txt with 10 lines each containing the sentence "Today is the day." Write the sentence only one time. 4.-Add the file doc01.txt at the beginning of file doc02.txt. 5.- Save the doc02.txt as doc03.txt 6.- In the document doc03.txt replace the word "Yesterday" by "Today" and the word "was" by the word "is". 7.- Save the file doc03.txt and exit vi. Submit the sequence of Linux statements and actions to do in order to execute the task described above. Copy the instruction of this exercise and write your answer below each question.

Explanation / Answer

1)
a) vi doc01.txt
Creates a new file if it already does not exist, otherwise opens an existing file.

b) i

Change into insert mode.

c) :1,10s/^/"Yesterday was the day"/
where 1 and 10 compose the line number range, and the "Yesterday was the day" is the text to be inserted at the beginning of the line.
----------------------------------------------------------------------
2)

d) ctrl-s
To save the text file

e)ESC
Press <Escape>.
    (You must be in insert or append mode if not, just start typing on a blank line to enter that mode)

f) :wq
    Press : <colon>.
    The cursor should reappear at the lower left corner of the screen beside a colon prompt. The colon indicates that what follows is a Vim command
    Enter the following:
                     wq
    Type “wq” , the “w” indicates that the file should be written, or saved which will overwrite existing file and the “q” indicates that vim should quit, or exit
    Then press <Enter>.
    This will quit the editor, and write all changes you have made; all changes to the document will be saved.
-----------------------------------------------------------------------
3)
a) vi doc02.txt
Creates a new file if it already does not exist, otherwise opens an existing file.

b) i

Change into insert mode.

c) :1,10s/^/"Yesterday was the day"/
-----------------------------------------------------------------------
4).
vi doc02.txt

To insert the contents of another file after a specific line in the current file:

   0:r doc01.txt

This inserts the contents of the file "doc01.txt" after line 0th line means begining of the current file.

-------------------------------------------------------------------

5)
a) :w doc03.txt                 It saves the file with name doc03.txt
   :q          It quits vi editor
-----------------------------------------------------------------
6)
vi doc03.txt
:s/"Yesterday"/"Today"/          replaces yesterday with today
:s/"was"/"is"/           replaces was with is
--------------------------------------------------------------
7)
:wq        It saves the contents and quit the vi ediotor

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote