zoukankan      html  css  js  c++  java
  • shell script数组使用函数输出

    #!/bin/bash
    #  array variable to function test
    
    function testit {
      local newarray
      newarray=("$@")
      echo "The new array value is: ${newarray[*]}"
    }
    
    myarray=(1 2 3 4 5)
    echo "The original array is ${myarray[*]}"
    testit ${myarray[*]}

    注意:

     function testit { 中函数名 testit 和 { 中间是必须加上空格的。

     myarray=(1 2 3 4 5) 中的 (1 2 3 4 5) 两边不能加上双引号,等号两边不能加上空格的。

    运行 sh test.sh 输出为:

    The original array is 1 2 3 4 5
    The new array value is: 1 2 3 4 5
  • 相关阅读:
    k8s-istio记录
    k8s
    单词 -(动物)
    RxJs
    .netcore 3.1 unbuntu
    单词规整
    AutoMapper
    时间
    ye
    特殊权限
  • 原文地址:https://www.cnblogs.com/jacson/p/4800054.html
Copyright © 2011-2022 走看看