awk Statistics IP Access times
Now there is a file, the amount of data in the 200多万条 record, want to use the shell of awk to do statistics, the file format is as follows#关键字 #url#ip Address #Test|123|1Test|123|1Test|123|2Test2|12|1Test2|123|1Test2|1
By curl the-w parameter we can customize the output of the curl,%{http_code} represents the HTTP status code
The code is as follows
Copy Code
# curl-i-M 10-o/dev/null-s-W%{http_code} www.111cn.net
The above
1 if statementThe format of the IF statement:If condition then command fiIf condition then command else command fiIf condition then command elif condition then command else command fiExample:Determines whether the current user is root, and if so,
* Multiple? 1 x# annotation Characters\ de-Righteous characters| Pipe character$ as a prefix for variables, used for variables!$ using the last parameter of the previous command; Used in the middle of two commands to write in one line~ User's Home
1, realize the bulk add 20 users, the user name is user1-20, password is user+123#!/bin/Bashcount=$1if[-N"$count"]then for((i=1; i)) DoUseradd-d/home/user_$i-s/bin/bash user_$i; Echo User_"$i"123|PASSWD--stdin user_$i; DoneElseEcho"$count is
What the shell means: First, the Shell's English meaning is "shell"; It is relative to the kernel, because it is proposed to be based on the core of a user-oriented form of expression, such as we see a ball, see its shell, rather than nuclear.
For example, there are the following files Test.txt1 134.102.173.432 134.102.173.433 134.102.171.424 134.102.170.9To count the most frequently occurring IPs, you can take advantage of the following shell script:Cat Test.txt | awk ' {print $} ' |
I. File systems and Securitychmod commandThe chmod command has two modes, one is the symbol mode, executes the user with the Ugo, executes the permission with the RWX, the other is the absolute mode, uses the different value of the octal different
1, when the script is run to specify parameters, directly behind the script name to follow the parameters to be added, in the process of running, "$" represents the program name, "$" represents the first parameter, the second parameter, the Nineth,
Shell in && | | Usage && operator: command1 && command2 && Left command (Command 1) returns True (that is, returns 0, successfully executed) after,&& The command on the right (command 2) can be executed, in other words, "If this command executes
1. Shell basic format, variable# Add an interpreter to the shell script #! /bin/bash# Print out Hello world with a script#! /bin/bashecho "Hello World"ExitParameters: A parameter is an entity that stores real values that are typically referenced in
Shell expressionWhether the-D file exists and is a directoryThe-f file is present and is a normal fileWhether the-W file file exists and is writable-s file exists and is not empty-N string string length not 0String1=string2 string Equality-eq equals-
TemplateCat delbak.sh#!/bin/shlocation= "/root/sqlbak/"Find $location-mtime +30-type f |xargs rm-fPs:Location is the directory where the lookup is set--mtime +30 is set time is 30 days ago-type F this week the type of lookup is fileThen add crontab
Before modifying the file name#!/bin/bask#for A in $ (ls/etc/yum.repos.d/centos*);d oif [$a! = '/etc/yum.repos.d/centos-media.repo '];then #CentO The S-media.repo file name does not modify the MV $a $a. bak
The original script check.sh:Monfile= "/var/log/test/testmon.txt"Logfile= "/var/log/test/testmon.log"Touch $monfile...The script is edited in window and uploaded to Linux after editing.Problem:After running, the file that appears in the directory is
1. Read basic reading 1 #!/bin/bash 2 #testing the Read command 3 4 Echo " Enter you name: " 5 Read name # 6echo"Hello $name, Welcome to my program. " Perform:#./read. SH Enter
Regular Expression - concept: A special syntax for describing text patterns -by ordinary characters (e.g., characters A to Z), and special characters (metacharacters, such as/ *?). And so on) make up a matching string--the text Filter tool supports
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service