Shell 脚本元组+for循环
#!/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循环的更多相关文章
- shell脚本之for循环
shell脚本之for循环 author :headsen chen 2017-10-18 09:50:41 个人原创,转载请注明.否则依法追究法律责任 1,cat forloop ...
- shell 脚本中所有循环语法
写出 shell 脚本中所有循环语法 for 循环 : for i in $(ls);do echo item:$i done while 循环 : #!/bin/bash COUNTER=0 whi ...
- centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 第三十六节课
centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 ...
- shell脚本中select循环语句用法
shell脚本中select循环语句 1. 脚本中select的语法格式 select VAR in LIST do command1 command2 ... ... commandN done s ...
- shell脚本进阶之循环判断
p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm; margin-bottom: .0001pt; text-align: justify; f ...
- shell 脚本中for循环
昨天很痛苦的搞了一天的for循环,在服务器上运行没啥问题,在设备上运行总是不行,部分代码如下: for(i=1;i<$cnt+1;i++)do echo "xxxx" &g ...
- Shell脚本- 单条命令循环执行重复工作
关于shell for循环具体详细说明可参考:http://wiki.jikexueyuan.com/project/linux-command/chap34.html example: 分别在com ...
- shell脚本程序中循环、判断语句的介绍
shell的循环主要有3种,for,while,until shell的分支判断主要有2种,if,case 一,for循环 C/C++ Code复制内容到剪贴板 #!/bin/bash for fil ...
- Shell脚本之for循环、while循环,if语句、case语句
1. for循环一般格式: 格式1: for((条件)) do 动作 done 格式2: for 变量名 in 范围 do 动作 done1234567891011121314实验:##1. 输出数字 ...
随机推荐
- DataTable插件报错:Uncaught TypeError: Cannot read property 'style' of undefined
DataTable插件报错:Uncaught TypeError: Cannot read property 'style' of undefined 原因:table 中定义的列和aoColumns ...
- 2019/3/28 wen 继承
- 剑指offer(6)旋转数组中的最小数字
题目描述 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转. 输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素. 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个 ...
- 解决ajax异步请求数据后swiper不能循环轮播(loop失效)问题、滑动后不能轮播的问题。
问题描述: 1.我使用axios异步请求后台的图片进行渲染后不能实现循环轮播,也就是loop失效,但是静态写死的情况下不会出现这种问题. 2. 分析: swiper的机制是:初始化的时候将swiper ...
- MATLAB raw格式转为bmp格式
今天是第一天写博客,哈哈哈!把完成的数字图像作业放上来和大家一起分享一下! 如果有什么问题,希望大家和我多多交流 1518234852@qq.com width=512; height=512; im ...
- JS和Jquery获取和修改label的值
获取值: label标签在JS和Jquery中使用不能像其他标签一样用value获取它的值: var label=document.getElementById("id");var ...
- yum downloadonly模式,保存所需软件及其依赖包
command: sudo yum install --downloadonly --downloaddir='yourderictory'
- 【Git】Git使用记录: 撤回已经commit到本地的提交记录
话不多说直接上步骤: git bash直接干到你的code. 直接敲命令: git reset --soft HEAD~1 搞定 就是这么简单粗暴. 如有顾虑请自行找个案例测试即可. 参考资料 htt ...
- [笔记] SQL性能优化 - 避免使用 IN 和 NOT IN
WHY? IN 和 NOT IN 是比较常用的关键字,为什么要尽量避免呢? 1.效率低 可以参看我之前遇到的一个例子([小问题笔记(九)] SQL语句Not IN 效率低,用 NOT EXISTS试试 ...
- Harbor私有仓库中如何彻底删除镜像释放存储空间?
简介: Harbor私有仓库运行一段时间后,仓库中存有大量镜像,会占用太多的存储空间.直接通过Harbor界面删除相关镜像,并不会自动删除存储中的文件和镜像.需要停止Harbor服务,执行垃圾回收命令 ...