Lesson 07 - Editing Text Files and Search Patterns
Lesson 07 - Editing Text Files and Search Patterns
The different keyboard characters used to switch from command mode to insert mode are given
below:
Option Description
i Inserts data before the current character
I Inserts data from the start of the current line
a Inserts data after current character
A Inserts data at the end of the line
o Adds data one line below the cursor
O Adds data one line above the cursor
Save and Quit File
The ? or / key is used to search for any specific string in the vi editor.
Jump a Line
The J command is used in the current line of data to join it with the next line of
data.
Navigate Through Files
The following options can be used along with grep command to perform the mentioned tasks:
Option Description
-o Output the matched parts of a matching line
-v Invert the match
-c Display the count of matching lines
-l Display the list of filenames
-n Display the matched lines and their line numbers
Key Takeaways
A. q
B. wq
C. mv
D. None of them
Knowledge
Check
Which command is used to save and quit the file in vi editor?
1
A. q
B. wq
C. mv
D. None of them
w is used to save a file, and q is used to quit. Therefore, wq is used to save and quit a file.
Knowledge
Check
Which command is used to copy the current line of the file?
2
A. yy
B. yw
C. yc
D. yz
Knowledge
Check
Which command is used to copy the current line of the file?
2
A. yy
B. yw
C. yc
D. yz
A. / or ?
B. s
C. F
D. t
Knowledge
Check
Which command is used to search for a string in the file using vi editor?
3
A. / or ?
B. s
C. F
D. t
A. J
B. F
C. GG
D. gg
Knowledge
Check
Which command is used to jump to the first line?
4
A. J
B. F
C. GG
D. gg