Shell is a command interpreter. It is an insulation layer between the operating system kernel and the user. To be precise, it is alsoA powerful computer language. A shellProgramIt is called a script and is a very easy-to-use tool.Combine system
The $ symbol in Bash is used to replace the parameter name with the value represented by the parameter. For $, braces are optional, that is, $ A and $ {A} represent the same parameter. $ {} There are several expressions with colons: $
Shell script debugging-run log 1
This article mainly describes how to output debug logs in shell scripts.
C/C ++ debug log
In C/C ++, _ file __, _ FUNC __, _ line _ indicates which log of the current row comes fromSource codeWhich
Tangent to Vertex
Returns a convex polygon.P, TangentLIsPIntersection andPInternalL.
This concept is similar to orthogonal tangent.
Pair of vertex points
If two verticesPAndQ(BelongP) In the two parallel tangent lines, they form a pair of
$1 indicates the first parameter. $ * indicates all parameters entered by the user.
The hello1 script is as follows. A location parameter is acceptable.
#! /Bin/bash
Echo $1
Run the Script:./hello1 "Hello World" and output Hello World on the
The Common commands of ADB shell in Android and the methods for viewing application database information under cmd are as follows:
CMD -- ADB shell: Enter the shell command interface of the simulator.
Ls displays all the file directories in the
1)
Create
FunctionName {
...
}
Or:
Name (){
...
}
2)
Call
Use the function name directly. The function can be called only after it is defined;
When a function has the same name, the new definition will overwrite the old definition and no
Shell scripting is an interpreted language;
The essence of shell scripts is an ordered set of shell commands;
1. Basic shell programming process
1) create a shell file
2) grant executable permissions to chmod A + x filename
3) execute the shell file.
In awk programming, do not forget that awk processes regular expressions. There are many internal functions, especially string processing functions. Calling these functions can reduce the workload.
1. Format
// Note \ There cannot be spaces behind
Chapter 2: handling user input
Command Line ParametersRead ParametersBASH Shell assigns some special variables called positional parameter to all the parameters entered by the command line.Even include the program name$0: Program name (Absolute
Chapter 2: using structured commands
Use the if-then statement
if commandthen commandsfi
If the exit status code of the command after if is 0, execute then.
Another Form
if command; then commandsfi
If-then-else statement
if commandthen
Shell sorting is a form of change in insert sorting. Because insert sorting compares each element and compares the current element with all the previous elements, in the worst case. Therefore, DL. shell proposed shell sorting in 1959, that is,
Some terminal shortcut keys:
CTRL + F
Forward one character
CTRL + B
Move one character behind
CTRL + E
Move to end of line
CTRL + L
Clear Screen
CTRL + d
Delete current
1. condition test
Two formats: test condition or [condition] (Note that spaces are added on both sides)Condition can be a logical operation of multiple sub-conditions. The logical operator numbers include:
-A logic and
-O logic or
! Logic No
&, |
2.
Shell script used to detect Processes
10:38:08 | category: centos | font size subscription
Script 1:
#! /Bin/sh
Program = XXXX # process name
Sn = 'ps-Ef | grep $ program | grep-V grep | awk '{print $2} ''# obtain the process port numberIf ["$ {sn}"
#! /Bin/sh
# Filename: 2.sh
B = 9
E = 15
Tmpb = $ B
While [$ tmpb-Le $ E]
Do
Echo $ tmpb
# Tmpb = 'expr $ tmpb + 1' // OK
Tmpb = $ (expr $ tmpb + 1)
Done
After the script is executed, the output result is:
9101112131415
Note: The
To determine whether the variables in a script are empty, I wrote a shell script like this:
#! /Bin/sh
# Filename: Test. Sh
Para1 =
If [! -N $ para1]; then
Echo "is null"
Else
Echo "not null"
Fi
Then run the Script: test. sh uses
Linux system resource load is too high and Apache shell script is automatically restarted
When we routinely maintain Apache Web servers in Linux, the endless loop caused by crawler crawling cannot jump out, or the collection of data from peers
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