Linux Chapter 6 after-school questions 6-4

It is known that there are two text files f1 and f2, cut and insert the 5th to 9th lines in the f1 file and paste them into the 3rd line of the f2 file, and then rewrite all the read strings in the f2 file as reading, Finally, append the current time after the f1 file. Use the vi editor to write the above operation steps and related commands.

Answer:
First use vi to open two text files f1 and f2, and execute the command as follows:
vi f1 f2
is edited under f1 at this time, move the cursor to line 5, execute the cut command
"b5dd
, and save the cut f1
:
After w , go to edit the f2 file
: n
enter f2, move the cursor to the third line, and execute the paste command
"bp
After pasting, rewrite all the read strings in the f2 file as reading, and execute the global replacement command
: g /read/s//reading/g
Finally, add the current time after the f1 file. The operation is as follows:
in the current editing state of the f2 file, save f2 first, and then return to the editing state of f1
: w
:e#
Enter f1 After editing, move the cursor to the bottom, execute the insert shell command, and insert the current time
: r !date

Guess you like

Origin blog.csdn.net/m0_67522355/article/details/125302937