awk command
Delete duplicate, non-contiguous rows
'awk'! a[$0]++'
awk separates columns with special separators
Echo " 192.168.102.134 " awk ' {print $4} '
SED command
Intercepting text in a time range in the program log
sed ' /^2015-05-14 15:32:30/,/^2015-05-14 16:12:09/p ' access_log > Log.txt
Sed to remove blank lines
secret= 'sed'/^$/d'filehead -1'
Replace word special characters with SED
Echo " 12,34,56 " sed ' s/,//g '
Replace the string contents between the two by SED
File contents
<id= "Film-web" address= "127.0.0.1" port= "6881" ></server>
[Email protected]/]#CatTest.txt<serverID="Film-web"address="127.0.0.1"port="6881"> </server>[[Email protected]/]#sed-N"s/\ (*server.*port=\ "\). *\ (\". *\)/\1abc\2/p"Test.txt<serverID="Film-web"address="127.0.0.1"port="ABC"> </server>[[Email protected]/]#sed-N"s/\ (*server.*address=\ "\). *\ (\" *port\)/\1abc\2/p"Test.txt<serverID="Film-web"address="ABC"port="6881"> </server>
Note: in sed, content enclosed in parentheses can be seen as a variable. Output using \ 1 and \.
See also: http://coolshell.cn/articles/9104.html parenthesis Matching
Sed "s/abc/123/g" test.txt to replace ABC with 123
grep command
Find text content, exclude. jar,. log files
grep -i-r--exclude=*.jar--exclude=*.log abc/home/
View Tomcat Log specific content
Cat grep grep awk ' {if ($ >) print $} '
View Tomcat logs for one day
Tail -800000grep-05 -. Log
grep or action
grep " pattern1|pattern2 " file . txt Egrep " pattern1|pattern2 " file. txt
grep Non-operational
grep ' pattern1 ' file. txt
-
PS Command
CPU/memory usage sort
ps auxw-- Sort =%cpu ps auxw "--sort =%mem
View End share population with
lsof-i:8080 ps -aux | grep Java ps -aux | grep pid
Kill command
Bulk Shutdown process
Kill -9 'PSgrep grep'grep'awk { ' Print $ '} `
Vim command
Vim Show/Hide line numbers
: Set Nu or: Set Number:set Nonu or: Set Nonumber
Vim replaces specified area matching text
Ten, s/10.13. 92.1/10.13. 92.2/g
Date command
Print Time
echo 'date'+%y-%m-%d%h:%m:%s'
Time display
Date Date ' +%y-%m-%d%h:%m:%s '
Tar command
Tar package file, exclude option to exclude specified file or directory
# # Package The current catalog file as a Pak. Tar . GZ, excluding the logs folder tar zcvf. /pkg.tar. GZ * --exclude=*.txt--exclude=logs
- The difference between BASHRC and profile
Https://wido.me/sunteya/understand-bashrc-and-profile