Please copy the/etc/init.d/iptables to the/root/directory and rename it to Test.txt:
Cp/etc/init.d/iptables Test.txt
MV Iptables Test.txt
Open Test.txt with vim and set line number:
Vim Test.txt
: Set Number
Move down, up, left, and right 5 characters: arrows or j,k,h,l
Two pages down and up, respectively: ctrl+f; Ctrl+b; PageUp; PageDown
Move the cursor to line 49th: 49G
Move the cursor to the end of the line, and then move to the beginning: shift+4; 0 or Shift+6
Move to the last line of the Test.txt file: G
Move to the first line of the file: GG
Search for the iptables that appear in the file and count the total number of occurrences:
Gg
/iptables Enter, press N to find the next
Replace the iptables from the first line to the third row with the iptable:
: 1,3s/iptables/iptable/g; #不加g仅替换每一行第一个, add g to replace all
Restore previous action: U
Replace all iptables in the entire file with iptable:
: 1, $s/iptables/iptable/g
Move the cursor to line 25 and delete the character "$":
25G
Press I to enter edit mode to delete.
Restore previous action: U
Delete Line 50th:
50G
Dd
Restore previous action: U
Delete everything from 37 rows to 42 rows:
37G
6dd
Restore previous action: U
Copy the 48 lines and paste them below the 52 lines:
48g;yy;52g;p; P Copy the data from the next line of the cursor paste, p from the previous line
Restore previous action (press two times u)
Copy the contents from 37 rows to 42 lines and paste them above the 44 lines:
37G
6yy
44G
P
Restore previous action (press two times u)
Move the contents of rows 37 to 42 below the 19 line:
37G
6dd
19G
P
Restore previous action (press two times u)
Move the cursor to the first line and change the/bin/sh to/bin/bash:
Gg
Press I to enter edit mode to modify
Insert a new line below the first line and enter "# hello!" :
Press the letter O and enter "hello!"
Save the document and exit:
: wq!
This article is from the "Llinux Command Contact" blog, please be sure to keep this source http://2767215.blog.51cto.com/2757215/1948226