1 detect the number and status of links to the Web server:
Netstat-ant|awk ' {print $ \ t ' $} ' |grep:: FFFF: ' |sed-e ' s/::ffff://'-e ' s/:[0-9]*//' |sort|uniq-c| Sort-rn|head-10
Results:122 125.162.71.199 time_wait79.119.125.43
Today's example is used to validate the legality of the parameters entered by the user, and the program is not complicated, as follows:
#!/bin/sh
# validalphanum-ensures that input consists only of alphabetical
# and numeric
Name
WC is a tool for statistics, all spelled as: Word count (Word statistics)
Instance:
1. Statistics of rows
$WC –l File
2. Statistics of words
$WC –w File
3. Statistics of characters
$WC –c File
4. Number of characters in the statistical
Shuf-n5 Main.txt
Sort-r Main.txt | Head-5
awk-vn=5-vc= "' wc-l file '" ' Begin{srand () while (n
While read Line;do echo "$line $RANDOM";d One
Options for the Shuf command:
-E,--echo: treat each parameter as an input line-I,--input-range=lo-hi:
In recent time, when dealing with shell scripts, encountered time processing problems. The addition and subtraction of time, as well as the calculation of timing.
I. Time Plus and minus
The way to do this is to turn the base time into a timestamp,
In the previous blog, once wrote the implementation of automated test procedures, now developers need to know the process of being tested (this refers to the main process running on Linux) before the abnormal exit of the process state, such as
For example, you might want to refer to the following implementation for a script that requires only sequential access to a resource, such as a disk file.
Copy Code code as follows:
#!/bin/bash
#
# File locking using Bash.
# ver 0.1.6
Shell string Comparisons, judging whether it's a number
Binary comparison operator, comparing variables or comparing numbers. Note the difference between numbers and strings.
Integer Comparisons
-eq equals, such as: if ["$a"-eq "$b"]
-ne is
3.1 Find textgrep: Use POSIX-defined basic regular Expressions (BRE).Egrep: Using an extended regular expression (ERE).Fgrep: Fast grep. Use the optimized algorithm to match a fixed string rather than a regular expression.
The 1992 POSIX standard
One, the definition function
Copy Code code as follows:
function fname ()
{
statements;
}
Or
Copy Code code as follows:
FName ()
{
statements;
}
Second, call function
You can call a
Copy Code code as follows:
#!/bin/bash
#********************************#
#并发后台运行fun #
#for Wanggy 2012-01-25 #
#note: #
#fun_num Fun function Background Run number #
#sql_num How many times per function SQL runs #
#**********************
The Linux shell is much more powerful in programming than in Windows batching, whether in loops or operations. There is no comparison of data types. The following is a summary of how an individual operates on an array while in use.
1. Array
Function Fly Shovel is simpler, just get the extranet IP. Some sites are processed for Curl UA.
Meet their own collection of addiction, collected a lot can be used to query the Internet IP URLs and methods.
#国内某网站的接口, only return IP
Curl ip.665
When the old horse wrote this version, I tested a simple reproduction of two 2003 version, when it is easy to use. I guess it's probably about 2003 dozen ms06014 patches. Kyo the solution at the freezing point forum, I studied this component this
&&Command 1 && Command 2: If this command executes successfully && then execute this command.[Jb]/usr/xxxx/ytcclb>ls-l Test.sql-rwxr--r--1 xxxx Group Nov 14:12 Test.sql[JB]/USR/XXXX/YTCCLB>CP test.sql Test.bak && echo "Coping file ok!"Coping file ok!
1. Preface
Almost six months did not write a blog, deserted for a long time, the work of the chores too much, their own more and more lazy. In order to spur their own growth, or adhere to write a blog, record their growth.
2. Introduction to Shell
The definition of a variable can only begin with a letter and an underscore, case-sensitive, and may contain a numeric letter underline. See Official Handbook
Copy Code code as follows:
[Root@svn shell_example]# yourname= ' Linux '
[
One, for loop1. Digital Segment Form
Copy Code code as follows:
For i in {1..10}
Todo
Echo $i
Done
2. Detailed list (character and number of items are not many)
Copy Code code as follows:
For File in 1 2 3
With Mint for some time, download basic with Firefox, and sometimes download a few g of the game. But Firefox didn't find the option to download the shutdown. In this reason, wrote this.
download_shutdown.sh
#!/bin/bash
# Created by: Demo
#
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