I. Write an SED command, modify the contents of the/tmp/input.txt file, request: (1) Delete all empty lines, (2) one row, if "11111" is included, insert "AAA" before "11111", insert "BBB" after "11111", For example: Change the line of content 0000111112222 to: 0000aaa11111bbb2222
(1) Sed '/^$/d '/tmp/input.txt (2) sed ' s/\ (11111\)/aaa\1bbb/g '/tmp/input.txt
Two. Sed multi-edit commands for files
(1) SED + option e format: sed-e ' sed command '-e ' sed command ' filenamesed-e ' s/seugrid1/seugrid1/'-e ' s/certificate/certificate/' input (2) The. sed + {} format is: sed ' sed command/{}; ' filenamesed '/certificate/{s/certificate/install/;s/your/your/;s/user/other/;} ' input (3 ). Separate multiple editing commands with semicolons. Format: sed ' edit command 1; edit command 2; Input file sed ' s/seugrid1/seugrid1/; s/certificate/certificate/' input
650) this.width=650; "title=" 450541 "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px, "alt=" 450541 "src=" http://s3.51cto.com/ Wyfs02/m00/86/99/wkiol1ffhbygrmjfaadpeo3h7oc513.jpg "border=" 0 "height=" 442 "/>
Three. Locate all normal files under the/tmp/directory whose names end with "_s1.jpg" and package them in the/tmp/back.tar.gz file if their modification date is within one day
There are three ways to do this:
(1) find/tmp-name ' *_s1.jpg '-mtime-1 | Xargs tar-zcvf/tmp/back.tar.gz (2) tar-zcvf/tmp/back.tar.gz $ (find/tmp-name ' *_s1.jpg '-mtime-1) (3) find/tmp-name ' * _s1.jpg '-mtime-1 | TAR-ZCVF/TMP/BACK.TAR.GZ-T-
Four. Find 3 methods for finding two suffix names
(1) Find. -name "*.txt"-o-name "*.log" (2) find. -regex ". *\. java\|. *\.xml "The above command will find all the Java files and XML files under the current folder, find the default use Emacs Regular, will be more verbose, if the use of posix-extended is relatively simple, as follows: (3) find. -regextype Posix-extended-regex ". *\. (Java|xml) "
Five. With the netstat command with other shell commands, according to the source IP statistics all the established status links to 80 ports, the output is similar (the first column of the number of connections, the second column IP):
Netstat-an | grep established | grep ": 8080" | awk ' begin{fs= ' [[: space:]:]+ '}{print $8} ' | Sort| uniq-c | sort-nr| Head-n 10
Six. Write a shell command that counts the number of accesses to each URL in the Apache log file (Access_log), and sorts the output in order of the number of times from small to large:
Cat Access_log|awk ' {print $7} ' | Sort | uniq-c | Sort-n | Head-10
Seven. View server TCP connection status and summarize
Netstat-an | awk '/tcp/{++a[$NF]}end{for (b in a) print b,a[b]} '
Eight. Statistics apace or Nginx log file access times up to 100IP and the number of times
awk ' {print '} ' access_log| Sort | uniq-c | Sort-n-K 1-r | Head-n 100
Nine. Every Monday three o'clock in the afternoon the/tmp/logs directory below the suffix *.log all the files rsync sync to the same directory in the backup server 192.168.1.100, crontab configuration items how to write:
* * * 1 RSYNC–VAZUTOPG--include= "*.log"--exclude=*/tmp/logs [email protected]:/tmp/logs--password-file=/etc/rsyncd /password.secret >>/var/logs/rsync.log 2>&1
10. Please write out the command that uses Tcpdump to crawl the package according to the following conditions: (1) The target port is 80, (2) The source IP is either 1.1.1.1, or 2.2.2.2; (3) UDP packet;
(1) tcpdump tcp-i eth0 DST Port (2) tcpdump src 1.1.1.1 or 2.2.2.2 (3) tcpdump UDP
This article is from the "Technical Achievement Dream" blog, please be sure to keep this source http://pizibaidu.blog.51cto.com/1361909/1844266
Several common commands for Linux