shell date处理
2015-11-11 14:39
148 查看
xyang@xyang-Latitude-E5440:~$ cat test.sh #!/bin/bash today=$(date +%F) if [ -n "$1" ];then today=$1 fi yesterday=$(date -d "${today} -1 day" +%F) afterweek=$(date -d "${today} +7 day" +%F) dt=$(date -d "${today} -1 day" +%Y%m%d) beforeweek=$(date -d"${today} -7 day" +%F) echo $today echo $yesterday echo $afterweek echo $dt echo $beforeweek xyang@xyang-Latitude-E5440:~$ bash test.sh 2015-11-11 2015-11-10 2015-11-18 20151110 2015-11-04 日期循环 begin_date="2016-01-01" final_date="2016-02-17" comparator=`date -d"$final_date" +%s` b_com=`date -d"$begin_date" +%s` while [ $b_com -lt $comparator ];do end_date=`date -d"$begin_date+1day" +%F` execute "$begin_date" "$end_date" begin_date=`date -d"$begin_date+1day" +%F` b_com=`date -d"$begin_date" +%s` done #!/bin/bash MYSQL="mysql -h192.168.243.27 -uroot -p488ff8a0-d690-11e4-8676-ab1b3be0671a -Db2c_push -N -e" begin_date="2016-02-15" final_date="2016-02-26" comparator=`date -d"$final_date" +%s` b_com=`date -d"$begin_date" +%s` function aa(){ while [ $b_com -lt $comparator ];do end_date=`date -d"$begin_date+1day" +%F` #execute "$begin_date" "$end_date" out_date=`date -d"$begin_date" +%Y%m%d` for((i=1;i<=22;i++));do sql="insert into everyday_push_20160226_${i}(uid,pid,gid,vid) select uid,pid,gid,vid from everyday_push_${out_date}_$i" $MYSQL"$sql" done begin_date=`date -d"$begin_date+1day" +%F` b_com=`date -d"$begin_date" +%s` done } function main(){ for((i=1;i<=22;i++));do sql="select count(1) from everyday_push_20160226_${i}" echo $i:`$MYSQL"$sql"` done } main
转载于:https://my.oschina.net/u/2510197/blog/528896
相关文章推荐
- shell date日期函数处理
- shell date处理
- shell处理时间date
- 第七章 Shell文本处理三剑客之sed
- 学习文本处理整理与常见的符号作用(shell 通配符 正则)
- 关于shell和文本处理
- shell处理大文件 http://longriver.me/?p=57
- DateUtil 工具类整理一些自己用到过得,有点逻辑处理的方法
- getopts 处理shell脚本参数
- shell 中常见问题处理记录
- shell脚本介绍、shell脚本结构和执行、date命令用法、shell脚本中的变量
- Oracle中PL/SQL引擎和SQL引擎DATE类型的不同处理
- module file out of date 错误处理
- Shell处理字符串常用方法
- shell-009: create 3 files named respectively by date
- SHELL 处理处理字符串的小结
- linux下shell处理nginx日志自动生成ip黑名单
- flex actionScript时间处理相加返回相加后的date
- [转载]【Shell脚本】逐行处理文本文件
- JS中Date的使用和字符处理