Question 1:
Open the file test.txt and move line 9 to line 5.
Answer:
vi test.txt
Switch to line mode and go to line 9:
:9
press Enter – you are on line 9. Cut this line – press:
dd
Switch to line mode again and go to line 5:
:5
Press Enter – you are on line 5. To paste cutted line to line 5 press Shift+P – paste above this line, so the current line becomes line 6 and pasted line – becomes line 5.:wq!
And press Entervi test.txt
there is a possibility that you’ll be on line 5 – per previous operation. Press:
gg
to get to the line 1.d3d
to delete first 3 lines.:wq!
And press Enter