Shell Learning Notes

Source: Internet
Author: User

#表示该脚本以bash方式运行1. #!/bin/bash# accepts the input and assigns the value to the variable 2. Read variable name               #使用变量3. ${variable name} #此变量只读4. readonly variable name          #删除此变量, cannot delete read-only variable 5. The unset variable name # represents the Pid6 of the current shell. $$# (ESS lower key) command replacement, will execute the knot The fruit is saved 7. var= ' command ' #计算8. Var= ' expr "            #注释9.
10. String     A. ' String '                         #单引号的字符串会原样输出, and the inside of the variable is not valid, and single quotation marks can no longer appear in single quotation marks, escaped also not     B. "String"                         #双引号字的符串, can have variables, can have escape characters     C. Greeting                         #连接字符串      d. ${#string}                       #获取字符中长度     E. ${string:1}/${string1:2}         #截取字符串     f. ' Expr index ${string} str '       #查找字符串 str, return index
11. Array     A. with "()" definition, use the "space" symbol to separate element     B. array[0]= "A"                      #定义指定下标的值, subscript can be discontinuous, subscript no upper limit     C. ${array[0]}                          #获取指定 The underlying value     D. ${array[*]}/${array[@]}       #获取数组所有元素     E. ${#array [*]}/${#array [@]} #获取数组长度     d. ${#array [n]}
    #获取数组指定下标的元素的长度
If...else     A. If [Express] #1. [There must be spaces on both sides], equivalent to if Test Express then command fi then #2. [$a = $b], the judge must also have a space between the command        if     b. If [Express] then Command1        else Command2        fi     c. If [Express] then        command1        elif then        command2        else Command3        fi
Case-  in-Case Express in #表达式可以是变量或常量, followed by in keyword Match1) #匹配值后跟) Command1 #匹配成功后执行命令;;  #跳出, equivalent to break macth2) Command2;;  *) #默认匹配值, equivalent to default command5;; Esac #结束符
-For-    var in exp1 exp2 exp3 #表达式用 "" (space) separate do        command    done
. while Whil [Express] #表达式为 true to continue doing command done
Until                                   unitl [Express] #表达式为 false to continue doing command done
Break/continue #跳出 or continue, followed by an integer representing the first layer of the loop
18. Functions A. function Func_name () {#定义函数, function can omit command} #只能返回整数数字, if no return value is specified, the result of the last command execution is returned B. func_name  #调用函数, do not need to add (), function to define C. $ ... $9 ${10} #取参数 before the call, the number of arguments more than 10 need to add {}
19. Input/Outbound redirection A. < input redirection B. > output redirection
20. References to other files a. FileName B. SOURCE FileName

The copyright of this article is owned by the author and the blog Park, the source website: http://www.cnblogs.com/code-boy/welcome you reprint, but without the author's consent, reprinted article must be in the article page obvious location to the author and the original text connection, otherwise reserves the right to pursue legal responsibility.

Shell Learning Notes

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.