[Note]shell Basics of function usage

Source: Internet
Author: User

Functions: Naming rules are the same as variables
Executing functions in the current shell process
Modularity of the program for easy maintenance

Basic function Syntax:

        function  function name ()          {             Command Area          }         #注:      The    #     function name can be directly connected to the following parentheses or separated by a space          #     keyword function and () One of the two can be omitted         #      before function calls need to be defined beforehand         #     The return value of the last command in the function represents the end state of the function         #     Execution encounters return immediate End Function call, and return value 0        #     command area use   Return n (0~255)   can specify a return value         #     The function is valid only in a defined shell environment         #     when a parameter is passed to a function, the function name is separated by a space between the arguments          #     variables defined in script are global variables relative to script, affecting their inner function area          #     use positional parameters $n to pass variable values instead of using variables         #      Use the local  variable name = variable value in a function to make the variable internal, without affecting the variable with the same name outside the function




^_^

This article is from the "junight" blog, make sure to keep this source http://junight.blog.51cto.com/10828785/1729866

[Note]shell Basics of function usage

Related Article

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.