shell遍历字符串数组

#!/bin/bash
arrayList=("ods_12_newepay_payment" 
"ods_13_newepay_return" 
"ods_15_pos_detail" 
"ods_16_pos_tender" 
"ods_31_tmall_head"
"ods_32_tmall_detail"
"ods_33_tmall_o2o_head"
"ods_34_tmall_o2o_detail"
)
length=${#arrayList[@]}
for ((i=0; i< length; i ++))
do
        cmd=${arrayList[i]}
        echo "cmd == $cmd"
        echo "select distinct data_invalid_type from crm_ods.$cmd" >> result.txt
        echo "" >> result.txt
        hive -e "select distinct data_invalid_type from crm_ods.$cmd" >> result.txt
        echo "" >> result.txt
        echo " ===================== " >> result.txt
done

你可能感兴趣的:(shell遍历字符串数组)