functions in the shell
The function is to organize a piece of code into a small unit, and give the small unit a name, when the code is used to call the name of the small unit directly.
The function must be placed first, since the call will not be written at the top, and the call will not succeed, and an error can be made.
The $ #和 $ $ In the script is a special variable. $ #是表示变量的个数, $ A is expressed
The name of the script.
Run results
2. Demand, call function get current IP
Ifconfig |grep-a1 "Ens33:" The//-A1 option is the line that filters out the keywords and the next line of keywords.
Ifconfig |grep-a1 "ens33:" |grep ' inet '//continue to filter only a row containing ' inet '
Ifconfig |grep-a1 "ens33:" |grep ' inet ' |awk ' {print $} '//filter out fields just for IP
Script content:
Execution results
、
Ii.Arrays in the shell
1.
The {} curly braces are used to print the array.
2
Test:
three, the alarm system needs analysis
Framework: Distributed
SHELLL (3) function, array, alarm system requirements analysis