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
Shell is an interactive command interpreter. Shell is independent of the operating system. This design allows you to flexibly choose the appropriate shell. Shell You can type a command in the command line,After being explained by shell, it is
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
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.
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.
I don't know when I wrote something, But I was found by archaeology when I sorted out the documents. I just smiled at those people who were bored. If the errors in this article cause all mental losses to you, contact the insurance company! Of course
Shell script Learning (1): Shell variables and some common commands
Shell allows you to create variables to store data, but does not support basic data type variables (such as int, float .....), shell interprets any value assigned to a
Iv. Loop Structure statements
Common shell loop statements include for loop, while loop, and until loop.
ForLoop
Syntax: for variable in list
Do
Operation
Done
Note: The variable is used inside the loop to refer to the object in the List currently
@ Rigorous use of set @
Set-eux
-E. If the command returns a non-zero value, exit immediately.
-U when the execution parameter is included, the unset variable is used as the error handling (if the extension attempt appears in the unset variable, the
Is there the same command as NBTSTAT in Linux! View other information through IP: Host Name, Mac, etc.
You can use nmblookup-a ip address.
You can also use nbtscan.
ARP command: ARP iPad. Local or ARP 192.168.1.108 or ARP-A or ARP
VI search string:
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