SHELL 循环获取日期以及FOR使用
2013-09-25 18:59
344 查看
for((i=1;i<=10;i++)); do PYTHONPATH=lib/ bin/cupid -c conf/config.cfg -u http://shop33220311.taobao.com/?tbpm=4 -s test/ -p xx; sz test/xx_*; done;
数组遍历:
SQL[0]=" DELETE FROM sight_area;" SQL[1]=" insert into public.sight_area(area_id,name,name_pinyin,area_path,type) select id,name,name_pinyin,area_path,type from mirror.sight where type not in ('景区','景点');" #循环遍历执行SQL for i in "${!SQL[@]}" do echo "${SQL[$i]}" | /opt/pg93/bin/psql -h l-tdata1.tkt.cn6.qunar.com -U pdata -s log_analysis done
简单的遍历数组
如数组:array=(element1 element2 element3 .... elementN)
for data in ${array[@]} do echo ${data} done
循环获取时间
#!/bin/bash startDay="2014-01-01" endDay="2014-12-31" while [ $startDay != $endDay ] do echo ${startDay}; startDay=`date -d "+1 day ${startDay}" +%Y-%m-%d` #关键步骤,获取第二天的时间 done
嵌套循环获取时间
#!/bin/bash start="2013-03-10" end="2013-03-14" platforms=("a" "b" "c" "d") date=$start tomo() { echo `date +%Y-%m-%d -d "$1 1 days"`; } end="`tomo $end`" while [ "$date" != "$end" ] do echo $date for p in ${platforms[*]} do echo $p #///todo done date="`tomo $date`" done
输出:
2013-03-10 a b c d 2013-03-11 a b c d 2013-03-12 a b c d 2013-03-13 a b c d 2013-03-14 a b c d
相关文章推荐
- shell scripts for 循环中变量赋值 以及 shell中sed的使用
- 微信小程序---for循环使用以及循环中的内容获取
- shell之菜单+跳板机(跳板机管理及连接脚本与下一个for循环的脚本配合使用)
- 例题:把一个超市购物的题做成函数。这个题做成函数没有必要,但可以了解输入参数,输出参数,返回值,函数体,还有结构体,ArryList集合,for循环算结果,以及集合里 .count的使用
- shell之for循环使用---更新中
- vue.js指令v-for使用以及下标索引的获取
- SHELLcase流程控制和for、while循环语句的使用
- linux中的for、while循环输出中赋值变量及shell中循环获取脚本参数
- shell中for循环使用
- Shell 脚本之循环语句(for,while,until)以及case,select,break,continue实例详解
- javascript中关键字in以及循环for...in的使用和注意事项
- 使用for、while 以及repeat-break实现循环语句
- 使用范围for语句和while循环以及传统for的区别
- linux shell for循环使用命令中读取到的值实例
- for循环语句以及break和continue的使用
- 在vim中使用shell命令的方法以及foreach循环的使用.
- 8.17_Linux之bash shell脚本编程入门篇(三)之循环以及函数function的使用
- vue.js指令v-for使用以及下标索引的获取
- shell脚本中for、while和do的使用以及区别
- 求1+2+…+n,要求不能使用乘除法、for、while、if、else、s witch、case 等关键字以及条件判断语句(A?B:C)和不用循环/goto/递归输出1~100的10种写法