shell遍历数组

JUMP_XCX=('xxx_111' 'yyy_222' 'zzz_333')
if [[ $JUMP_XCX != '' ]]; then # 可以判断空字符串 和 空数组
    NEW_JUMP_XCX=''
    for v in ${JUMP_XCX[@]};do
        if [[ $NEW_JUMP_XCX = '' ]];then
            NEW_JUMP_XCX+="'$v'"
        else
            NEW_JUMP_XCX+=",'$v'"
        fi        
    done
    sed -i "s#^\$jump_xcx.*;#\$jump_xcx=[${NEW_JUMP_XCX}];#g" $uniform_file
fi

处理成php数组

$jump_xcx=['xxx_111','yyy_222','zzz_333'];

什么数组不数组的,本质都是字符串。

posted @ 2020-06-20 09:44  TBHacker  阅读(530)  评论(0编辑  收藏  举报