#!/bin/bash
#by:V log_dir=(/data/logs/anjubao_syncapi /data/logs/anjubao_wechat)
daytime=`date -d ' -1 day ' +%Y%m%d`
datatemp=/data/debugtemp if [ ! -d $datatemp ];then
mkdir -p $datatemp
fi for i in ${log_dir[@]}
do if [ ! -d $i ];then
echo 'log_dir error'
exit 0
fi logname1=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==1 {print $7}'`
logname2=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==2 {print $7}'`
logname3=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==3 {print $7}'`
logname4=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==4 {print $7}'`
logname5=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==5 {print $7}'`
logname6=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==6 {print $7}'`
logname7=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==7 {print $7}'`
logname8=`ls -lt --time-style="+%Y%m%d" $i|grep -w $daytime|awk ' NR==8 {print $7}'`
tag=`echo $i|awk -F"/" '{print $4}'`
cd $i tar -czf $datatemp/ip175_$daytime-$tag.tar.gz $logname1 $logname2 $logname3 $logname4 $logname5 $logname6 $logname7 $logname8 if [ $? -eq 0 ];then
echo "hh"

Shell 脚本元组+for循环的更多相关文章

  1. shell脚本之for循环

    shell脚本之for循环 author :headsen  chen       2017-10-18    09:50:41 个人原创,转载请注明.否则依法追究法律责任 1,cat forloop ...

  2. shell 脚本中所有循环语法

    写出 shell 脚本中所有循环语法 for 循环 : for i in $(ls);do echo item:$i done while 循环 : #!/bin/bash COUNTER=0 whi ...

  3. centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 第三十六节课

    centos  shell脚本编程2 if 判断  case判断   shell脚本中的循环  for   while   shell中的函数  break  continue  test 命令   ...

  4. shell脚本中select循环语句用法

    shell脚本中select循环语句 1. 脚本中select的语法格式 select VAR in LIST do command1 command2 ... ... commandN done s ...

  5. shell脚本进阶之循环判断

    p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm; margin-bottom: .0001pt; text-align: justify; f ...

  6. shell 脚本中for循环

    昨天很痛苦的搞了一天的for循环,在服务器上运行没啥问题,在设备上运行总是不行,部分代码如下: for(i=1;i<$cnt+1;i++)do echo "xxxx"  &g ...

  7. Shell脚本- 单条命令循环执行重复工作

    关于shell for循环具体详细说明可参考:http://wiki.jikexueyuan.com/project/linux-command/chap34.html example: 分别在com ...

  8. shell脚本程序中循环、判断语句的介绍

    shell的循环主要有3种,for,while,until shell的分支判断主要有2种,if,case 一,for循环 C/C++ Code复制内容到剪贴板 #!/bin/bash for fil ...

  9. Shell脚本之for循环、while循环,if语句、case语句

    1. for循环一般格式: 格式1: for((条件)) do 动作 done 格式2: for 变量名 in 范围 do 动作 done1234567891011121314实验:##1. 输出数字 ...

随机推荐

  1. java开发中中文编码问题

    //ajax以get方式提交,字符串中包含中文 //后台struts中对该string的set方法中 this.jsonString = new String(jsoString.getBytes(& ...

  2. Redis学习-string数据类型

    Redis 是一个开源的使用 ANSI C 语言编写.支持网络.可基于内存亦可持久化的日志 型.Key-Value 数据库. redis提供五种数据类型string,hash,list,set及sor ...

  3. 剑指offer(51)构建乘积数组

    题目描述 给定一个数组A[0,1,...,n-1],请构建一个数组B[0,1,...,n-1],其中B中的元素B[i]=A[0]*A[1]*...*A[i-1]*A[i+1]*...*A[n-1].不 ...

  4. 【Python65--tkinter:button】

    一.需求:在Label页面增加一个按钮,点击此按钮,页面内容进行变化 思路: 1.上面放一个Label,下面放一个Button 2.采用frame框架 from tkinter import * #定 ...

  5. Injection的简单辨析

    依赖注入(injection)是一种对任何编程语言都有效的概念.依赖注入背后的一般概念称为控制反转.根据这个概念,类不应该静态配置其依赖项,而应该从外部配置. 如果Java类使用此类的实例,则Java ...

  6. 深入学习IOZone【转】

    本文转载自:https://blog.csdn.net/werm520/article/details/7262103 深入学习IOZone 刘智朋       2011-3-29 1        ...

  7. Python入门 日志打印

    logging # logging导入 import logging # 设置打印的最低级别 logging.basicConfig(level = logging.DEBUG) 使用 debug, ...

  8. CBV与FBV

    FBV FBV(function base views)就是在 url 中一个路径对应一个函数 urls.py urlpatterns = [ url(r'^admin/', admin.site.u ...

  9. easyUI使用dailog实现弹出框带表单功能

    本文为博主原创,未经允许不得转载: 示例如下: 需要注意的地方在id为win的div中需要有:closed="true"这个属性,这个属性为控制dailogn对话框显示与隐藏的属性 ...

  10. GPU并行的基础知识