copyarray.sh

来自「Shall高级编程」· Shell 代码 · 共 66 行

SH
66
字号
#! /bin/bash# CopyArray.sh## This script written by Michael Zick.# Used here with permission.#  How-To "Pass by Name & Return by Name"#+ or "Building your own assignment statement".CpArray_Mac() {# Assignment Command Statement Builder    echo -n 'eval '    echo -n "$2"                    # Destination name    echo -n '=( ${'    echo -n "$1"                    # Source name    echo -n '[@]} )'# That could all be a single command.# Matter of style only.}declare -f CopyArray                # Function "Pointer"CopyArray=CpArray_Mac               # Statement BuilderHype(){# Hype the array named $1.# (Splice it together with array containing "Really Rocks".)# Return in array named $2.    local -a TMP    local -a hype=( Really Rocks )    $($CopyArray $1 TMP)    TMP=( ${TMP[@]} ${hype[@]} )    $($CopyArray TMP $2)}declare -a before=( Advanced Bash Scripting )declare -a afterecho "Array Before = ${before[@]}"Hype before afterecho "Array After = ${after[@]}"# Too much hype?echo "What ${after[@]:3:2}?"declare -a modest=( ${after[@]:2:1} ${after[@]:3:2} )#                    ---- substring extraction ----echo "Array Modest = ${modest[@]}"# What happened to 'before' ?echo "Array Before = ${before[@]}"exit 0

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?