#!/bin/bash
:<<!
被注释的多行内容
!
:<<!
##arr_db_table=([0, 12, "10.30.16.x"], [13, 24, "10.30.a.b"])
##arr_db_table=(1 2 3)
arr_db_table=((0 12 "10.30.16.x"), (13 24 "10.30.a.b"))
for var in ${arr_db_table[@]};
do
echo $var
done
!
##cmd="select userid, type, value from game_db_00.attr_table_00 where type=121462 and value > 7"
##cnt=$(mysql -h10.30.16.237 -uxx -pc@@@# -s -e "${cmd}")
##echo "Current count is : ${cnt}"
##exit
:<<!
sites=("www.a.com www.b.com www.c.com www.d.com" "www.e.cn www.f.cn")
n_sites=${#sites[*]} #获取一维sites的数组长度
for ((i=0;i<$n_sites;i++));
do
inner_sites=(${sites[$i]}) #将一维sites字符串赋值到数组
n_inner_sites=${#inner_sites[*]} #获取二位sites的数组长度
for ((j=0;j<$n_inner_sites;j++));
do
echo ${inner_sites[$j]} #»ØÏÔsite
#do something
done
done
!
arr_db_table=("0 12 \"10.30.16.237\"" "13 24 \"10.30.16.x\"" "25 37 \"10.30.16.x\"" )
arr_db_table=("0 12 10.30.16.237" "13 24 10.30.16.x" "25 37 10.30.16.x" )
db_num=${#arr_db_table[*]}
echo $db_num
for ((i=0; i<$db_num; i++));
do
db_info=(${arr_db_table[$i]})
arg_num=(${#db_info[*]})
echo "arg_num:$arg_num"
game_db_begin=${db_info[0]}
game_db_end=${db_info[1]}
game_db_ip=${db_info[2]}
echo "begin:$game_db_begin"
echo "end:$game_db_end"
echo "game_db_ip:$game_db_ip"
for ((db_id=$game_db_begin; db_id <= $game_db_end; db_id++));
do
format_db_id=`printf "%02d" $db_id`
db_name="game_db_$format_db_id"
for ((tb_id=0; tb_id<=99; tb_id++));
do
format_tb_id=`printf "%02d" $tb_id`
tb_name="attr_table_$format_tb_id"
db_tb_name="$db_name.$tb_name"
##echo "db_table_name:$db_tb_name"
user="c"
pass="cps"
cmd="select userid, type, value from $tb_name where type=121462 and value>7"
result=`mysql -h$game_db_ip -u$user -p$pass -D $db_name -e "${cmd}"`
##echo "db_host:$game_db_ip"
echo $result
done
##echo "db_name:$db_name"
done
##:<<!
for ((j=0; j<$arg_num; j++));
do
echo ${db_info[$j]}
done
##!
done
echo "hello hello hello"
num=0
format_num=`printf "%02d" $num`
echo "format_num:$format_num"
:<<!
被注释的多行内容
!
:<<!
##arr_db_table=([0, 12, "10.30.16.x"], [13, 24, "10.30.a.b"])
##arr_db_table=(1 2 3)
arr_db_table=((0 12 "10.30.16.x"), (13 24 "10.30.a.b"))
for var in ${arr_db_table[@]};
do
echo $var
done
!
##cmd="select userid, type, value from game_db_00.attr_table_00 where type=121462 and value > 7"
##cnt=$(mysql -h10.30.16.237 -uxx -pc@@@# -s -e "${cmd}")
##echo "Current count is : ${cnt}"
##exit
:<<!
sites=("www.a.com www.b.com www.c.com www.d.com" "www.e.cn www.f.cn")
n_sites=${#sites[*]} #获取一维sites的数组长度
for ((i=0;i<$n_sites;i++));
do
inner_sites=(${sites[$i]}) #将一维sites字符串赋值到数组
n_inner_sites=${#inner_sites[*]} #获取二位sites的数组长度
for ((j=0;j<$n_inner_sites;j++));
do
echo ${inner_sites[$j]} #»ØÏÔsite
#do something
done
done
!
arr_db_table=("0 12 \"10.30.16.237\"" "13 24 \"10.30.16.x\"" "25 37 \"10.30.16.x\"" )
arr_db_table=("0 12 10.30.16.237" "13 24 10.30.16.x" "25 37 10.30.16.x" )
db_num=${#arr_db_table[*]}
echo $db_num
for ((i=0; i<$db_num; i++));
do
db_info=(${arr_db_table[$i]})
arg_num=(${#db_info[*]})
echo "arg_num:$arg_num"
game_db_begin=${db_info[0]}
game_db_end=${db_info[1]}
game_db_ip=${db_info[2]}
echo "begin:$game_db_begin"
echo "end:$game_db_end"
echo "game_db_ip:$game_db_ip"
for ((db_id=$game_db_begin; db_id <= $game_db_end; db_id++));
do
format_db_id=`printf "%02d" $db_id`
db_name="game_db_$format_db_id"
for ((tb_id=0; tb_id<=99; tb_id++));
do
format_tb_id=`printf "%02d" $tb_id`
tb_name="attr_table_$format_tb_id"
db_tb_name="$db_name.$tb_name"
##echo "db_table_name:$db_tb_name"
user="c"
pass="cps"
cmd="select userid, type, value from $tb_name where type=121462 and value>7"
result=`mysql -h$game_db_ip -u$user -p$pass -D $db_name -e "${cmd}"`
##echo "db_host:$game_db_ip"
echo $result
done
##echo "db_name:$db_name"
done
##:<<!
for ((j=0; j<$arg_num; j++));
do
echo ${db_info[$j]}
done
##!
done
echo "hello hello hello"
num=0
format_num=`printf "%02d" $num`
echo "format_num:$format_num"