shell切割字符串成数组

v='aaa_111'
array=(${v//_/ }) # 注意后面有空格
# 增加跳转小程序配置
if [[ $JUMP_XCX != '' ]]; then # 可以判断空字符串 和 空数组
    NEW_JUMP_XCX=''
    for v in ${JUMP_XCX[@]};do
        array=(${v//_/ }) # 注意后面有空格
        if [[ $NEW_JUMP_XCX = '' ]];then
            NEW_JUMP_XCX+="'${array[0]}'"
        else
            NEW_JUMP_XCX+=",'${array[0]}'"
        fi        
    done
    sed -i "s#navigateToMiniProgramAppIdList:.*#navigateToMiniProgramAppIdList: [${NEW_JUMP_XCX}],#g" $taro_src_appjsx_file
fi

你可能感兴趣的:(shell切割字符串成数组)