Tips: Linux 中 当形参名称是 变量时,如何取出全部的实参

点击查看代码
AutoHelpOther=true
UserSum=20
TempBlockCookie=2
MyFruit1="1111"
MyFruit2="222"

function Combin_Sub() {
  CombinAll=""
  if [[ ${AutoHelpOther} == true ]] && [[ $1 == ForOther* ]]; then

    ForOtherAll=""
    MyName=$(echo $1 | perl -pe "s|ForOther|My|")

    for ((m = 1; m <= ${UserSum}; m++)); do
      TmpA=${MyName}$m
      TmpB=${!TmpA}
        echo $TmpA A $m
        echo $TmpB B $m
            ForOtherAll="${ForOtherAll}@${TmpB}"

    done
 #   echo $ForOtherAll
    for ((n = 1; n <= ${UserSum}; n++)); do
      for num in ${TempBlockCookie}; do
        [[ $n -eq $num ]] && continue 2
      done
      CombinAll="${CombinAll}&${ForOtherAll}"
    done
 #   echo $CombinAll
fi
}
Combin_Sub ForOtherFruit

原文地址:https://www.cnblogs.com/vmsky/p/15490629.html