Vim command
Replace:
%s/aaa/bbb/
%s/aaa/bbb/g
Regular Expressions:
^ Opening
$ end
[0-9] Number
[A-z] lowercase
[A-z] capitalization
[^a-z] Non-lowercase
{1,3} 1 to 3 times
. Any single character, except \ r \ n
* 0 times to several times
? 0 times to 1 times
+ 1 times to multiple times
SED command
Suitable for handling row-related
Replace:
Sed ' s/aaa/bbb/g ' xx.sh
Sed-i ' s/aaa/bbb/g ' xx.sh
Sed ' s//\n/g ' xx.sh
Add a space at the beginning of each line:
Sed ' s/^/&/g ' xx.sh
Add one at the end of each line:
Sed ' s/$/& xiaofan/g ' xx.sh
Locate the row containing Nginx and add the ##### #字符 to his next line:
Sed '/nginx/a ###### ' xx.sh
Locate the row containing Nginx and add ##### #字符 to his previous line:
Sed '/nginx/i ###### ' xx.sh
Match a row and print:
Sed-n '/nginx/p ' xx.sh
Print 1--3 Line:
Sed-n ' 1,3p ' xx.sh
Print the first and last line:
Sed-n ' 1p; $p ' xx.sh
grep command
Filtration (combined with regular use)
-E using Perl regular
-V does not match
-N Print line number
-O outputs only matches to content instead of entire rows
-I ignores case
Match the line of the AA string:
grep "AA" xx.sh
Matches the line of the AA string and the top 2 lines:
Grep-b2 "AA" xx.sh
Matches the line of the AA string and the next 2 lines:
GREP-A2 "AA" xx.sh
Matches the line of the AA string and the top and bottom 2 lines:
Grep-2 "AA" xx.sh
awk command
Awk-f ' {print ($)} ' xx.sh
awk ' $3>90 {print $} ' xx.sh
awk ' {if ($1== "Boo" | | $3==84) print $} ' xx.sh
Netstat-an|awk '/^tcp/{++s[$NF]} END {for (i in S) print S[i],i} '
-F Specify delimiter
Full line
First column
$ second Column
$NF last Column
$NR
How many columns NF has
NR number of rows that have been read
Find command
Find./-maxdepth 1-name "*.sh"
Find./-mandepth 1-type f-name "*.sh"
Modified 7 days ago:
Find./-mtime +7
Modified in the same day:
Find./-mtime-1
Find files larger than 20M in the first layer of the current directory:
Find./-maxdepth 1-size +20m-type F
Locate and perform subsequent actions:
Find./-mtime +7 | Xargs RM-RF
Find./-mtime +7 | Xargs RM-RF \;
Find./-mtime +7-exec RM-RF {} \;
Find./-mtime +7-exec cp {}/tmp/\;
The Four musketeers in shell programming