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. 输出数字 ...
随机推荐
- NET的基本用法
NET的基本用法 NET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP | HELPMSG | LOCALGROUP ...
- 算法(第四版)C# 习题题解——1.1
写在前面 整个项目都托管在了 Github 上:https://github.com/ikesnowy/Algorithms-4th-Edition-in-Csharp 善用 Ctrl + F 查找题 ...
- overture不同行的音符应该如何连线?
钢琴初学者在使用overture的时候,碰到不同行中的音符想要将其连线,肯定会疑惑如何来完成这个操作.Overture作为一款钢琴爱好者喜爱的钢琴打谱作曲软件,有着十分强大的功能,下面,我们来看看如何 ...
- windows升级node
之前用的node版本太低,不兼容webpack4.x,需要升级,网上搜索了许多方法,发现在windows下行不通 找到的教程都说全局安装node下的一个名为n的模块,这个模块是node专门用于版本管理 ...
- 【BZOJ1485】有趣的数列
Description 我们称一个长度为2n的数列是有趣的,当且仅当该数列满足以下三个条件: (1)它是从1到2n共2n个整数的一个排列{ai}: (2)所有的奇数项满足a1<a3<…&l ...
- 洛谷 P1856 【Picture】
题目描述 N(N<5000) 张矩形的海报,照片和其他同样形状的图片贴在墙上.它们的边都是垂直的或水平的.每个矩形可以部分或者全部覆盖其他矩形.所有的矩形组成的集合的轮廓称为周长.写一个程序计算 ...
- 近期Freecodecamp问题总结
最近没什么事,刷了freecodecamp的算法题,发现了自己基础的薄弱 1 where are thou 写一个 function,它遍历一个对象数组(第一个参数)并返回一个包含相匹配的属性-值对( ...
- 初始FreeMake
此文章是观看视频学习的,只是一点点基础还不太深 视频地址:http://www.icoolxue.com/play/5773 源码:码云:https://gitee.com/wmjGood/FreeM ...
- Docker安装Tomcat镜像并部署web项目
一.安装Tomcat 1.查找Docker Hub上的tomcat镜像 docker search tomcat 2.拉取官方的镜像 docker pull tomcat 等待下载完毕,需要一些时间. ...
- Angular 学习笔记 (久久没有写 angular 常会忘记的小细节)
由于经常跑去写后端, 而且一些就几个月...很多 ng 的东西就忘掉了. 写在这里方便复习呗. 1. async pipe 没有 resolve 前返回的值是 null 2 view componen ...