SHELLL (3) function, array, alarm system requirements analysis

Source: Internet
Author: User

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

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.