0 Basic Learning Cloud computing and Big Data DBA cluster Architect "Linux Bash shell Programming and system Automation January 13, 2015 Wednesday"

Source: Internet
Author: User

function1. Role1call a piece of code repeatedly2) to categorize the code snippets.2. Set function name () {Body of code}3. Function name4. Return value using $?viewing the return value of 0 represents the correct, non-0 representation of the incorrect. The return value of the function refers to the value that needs to be returned to the caller after the function ends. Use return to follow the numbers to specify the return value5The position parameter of the function refers to the first argument passed to the function, and the second argument is passed to the function. Fun () {Echo$1        Echo$2        Echo$3}result=$ (Fun1 2 3)Echo$result [[email protected]~]# bash CANSHU1.SH 1 2 36. Example #!/bin/bashshell_like () { Case$1 inchYes) return0 ;; NO) return1 ;; *) return1 ;; Esac}# forIinch{1.. About}# DoRead-P"does u like shell?"RepifShell_like"$rep" Then        Echo "Me,too"&&ExitElse        Echo "input Error,retry"fi# Done7global variables and local variables. Global variable: is a variable local variable that is valid for all contents of a script: is the definition of a local variable that is only valid for code snippets within a function locally a=1title: Bash xxxx.SHInput-T5represents a triangle with 5 lines of paint-L7represents a draw slash 7 lines #!/bin/Bashtriangle () { forXinch$(seq 1$1) Do         forYinch$(seq 1$(($1-$x)))  Do                Echo-N" "         Done         forZinch$(seq 1$((2* $x-1)))         Do                Echo-N"&"         DoneEcho Done}line () { forIinch$(seq 1$1) Do         forXinch$(seq 1$i) Do             Echo-N" "         DoneEcho-N"^"Echo Done} Case$1 inch-t) TRIANGLE" $" ;; -l) Line" $" ;;Esac~

0 Basic Learning Cloud computing and Big Data DBA cluster Architect "Linux Bash shell Programming and system Automation January 13, 2015 Wednesday"

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.