Character test:
= = Test whether equal, want to wait for true, not equal to False
! =: Test whether unequal, not equal to true, and so false
Loop: Enter condition, exit condition
For
While
Until
for variable in list;
Loop body
Done
For I in 1 2 3 4 5;do
Addition operation
Done
After the traversal is completed, exit;
How to generate a list:
{1..100}
' SEQ [start number [step length]] End number '
Vim Editor
Full screen editor, modal editor
Vim mode:
Edit mode (Command mode)
Input mode
Last-line mode
Mode conversion:
Edit--Input:
I: In front of the character of the current cursor, switch to input mode;
A: After the character of the current cursor, switch to input mode;
O: At the bottom of the current cursor line, create a new row and switch to input mode;
First, open the file
# Vim/path/to/somefile
Vim +#: Open the file and locate it on line #
Vim +: Open the file and navigate to the last line
Vim +/pattern: Open the file and navigate to the beginning of the line that was first matched to the PATTERN
Second, close the file
1, the last line mode closed file
: Q exit
: Wq Save and exit
: q! Do not save and exit
: W Save
: w! Forcibly saved
: Wq---: X
2. Exit in edit mode
ZZ: Save and exit
Four Turn screen
CTRL+F: Flip one screen down
Ctrl+b: Turn up one screen
Ctrl+d: Flip Down half screen
Ctrl+u: Flip up half screen
Five delete a single character
X: Delete a single character at the cursor location
#x: Remove the total # characters from the cursor and backwards
Six Delete command: D
DD: Deletes the current cursor in the row
#dd: Delete the # line including the line where the current cursor is located
Seven, Paste command p
Eight, copy command y
Usage with D
Xi. Undo the previous edit Operation U
12. Repeat the previous edit operation
14. Find
/pattern looking at the tail
?/pattern to the header
XV, find and replace
Use the S command in the last-line mode
Addr1,[email Protected]@[email protected]
G: Indicates global I: Ignores case
%: Full text
Exercise: Replace Ftp://test.test.com/pub in the/mnt/test file with http://t-rex.cn
:%[email protected]ftp://test\.test\.com/[email protected]://[email protected]
16. Use Vim to edit multiple files
Vim FILE1 FILE2 FILE3
: Next switches to the next file
:p Rev Switch to the previous file
: Last switch to final file
: first to switch to file one
Exit
: QA All exits
17, split screen display a file
Ctrl+w, S: Horizontal splitter window
Ctrl+w, V: Vertical splitter window
Toggle the cursor between windows:
Ctrl+w,arrow
: QA Closes all windows
18. Edit multiple files in a window
Vim-o: Horizontal Split display
Vim-o: Vertical Split display
19. Save some of the contents of the current file as a different file
Use the W command in the last row mode
: W
: Addr1,addr2w/path/to/somewhere
20. Populate the contents of another file in the current file
: R/path/to/somefile
21. Interacting with the shell
:! COMMAND
22. Advanced
1. Display or suppress line numbers
: Set Number
: Set Nu (abbreviated)
: Set Nonu cancel notation
2. Display ignores or distinguishes character case
: Set ignorecase
: Set IC
3. Set Auto Indent
: Set Autoindent
: Set AI
: Set Noai
4. Check the found text highlighting or canceling
: Set Hlsearch
: Set Nohlsearch
5. Syntax highlighting
: Syntax on
: Syntax off
23. Configuration Files
/ETC/VIMRC (global scope is effective for all users)
~/.VIMRC hidden files in the personal directory
Practice:
1, add 10 users user1 to User10, password with the user name: but requires only the user does not exist in the case
To add
#!/bin/bash
#
For I in {1..10}; Do
If ID user$i $>/dev/null; Then
echo "User already exists"
Else
Useradd user$i
echo user$i | Password--stdin user$i &>/dev/null
echo "User$i User Add Complete"
Fi
Done
Vim Editor Detailed