1. VI Editor Shortcut Key memo
[CTRL] + [UD] Move up/down half page
N <space> shifted to n characters
H/m/l move to the top/center/bottom line of the screen
U [CTRL] + R restore and redo
. (Point) Repeat the previous action
: E! Restore a file to its original state
[CTRL] + V Block Selection
2. bash shell Basics
ENV Environment Variables
Set environment variables and other variables
The export changes the variable to an environment variable and takes effect in the subroutine.
Read-P followed by the prompt character,-t wait seconds
Declare declares the attributes of a variable.
-A is defined as an array.
-I is defined as an integer.
-X is the same as export and becomes an environment variable.
-R read-only attribute
History command
/Etc/issue Terminal interface string (use man issue or man mingetty to view the meaning of special code)
/Etc/motd get messages after Logon
System Setting Value:
/Etc/sysconfig/i18n data
Important variables such as/etc/profile path, user, mail, hostname, histsize, and umask are required to read other files, such as/etc/profile. D and/etc/inputrc.
Login Shell:
The shell obtained by the user when logging on to the Linux system corresponds to the last data in/etc/passwd. For example, if I want the user to directly open VI after atom login, change the last item of the line corresponding to atom in/etc/passwd to/usr/bin/VI.
3. Summary of common Linux text processing tools
A) Cut-D 'delimiter'-F fields, and obtain the fields segment separated by a separator.
The cut-C field ranges from characters to fixed character ranges.
B) CAT/etc/passwd | sort-t': '-K 3-N
-T, delimiter. The default value is the tab key.-K indicates the number of fields.-N indicates that the fields are sorted by pure numbers.
C) Others, WC [-LWM]; uniq [-ic]; tee [-A], bidirectional redirection
D) String Conversion command: TR, Col, join (merge the same data in two files), paste (directly paste the two rows together), expand (Convert [Tab] to a space key)
E) split the file
F)-(minus signs) Some commands need to use the file name for processing. stdin and stdout can be replaced by minus signs.
4. awk learning Summary
Awk is "processing by behavior Unit", while "processing by field is the smallest unit ".
Meanings of variable names
Total number of fields owned by each line of NF ($0)
Nr is currently processing the "row number" Data
FS separator. The default value is Space key.
You can use the begin keyword to preset awk variables, such:
CAT/etc/passwd | awk 'in in {FS = ":" }3 3 <10 {print $1 "\ t" $3 }'
Note: All operations on {} can be separated by semicolons (;) if multiple commands are required, or each command can be separated by pressing [enter.
5. Trace and debug shell scripts
Sh [-nvx] scripts. Sh
-N: No script execution, only query syntax Problems
-V first outputs the script content to the screen before executing the script
-X displays the script content on the screen for debugging.