码迷,mamicode.com
首页 > 系统相关 > 详细

shell脚本递归压缩实践

时间:2018-07-27 21:06:08      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:log   dep   ash   done   shel   pre   awk   脚本   data   

#!/bin/bash

Src_Path=/data/www/logs

Dst_Path=/data/www/logs_bak

for rfile in `find $Src_Path/ -depth -maxdepth 1 -type f |awk -F ‘/‘ ‘{print $NF}‘`

do

tar -zcPvf $Dst_Path/$rfile.tar.gz $Src_Path/$rfile

done

for dir in `find $Src_Path/* -type d|awk -F ‘/‘ ‘{print $NF}‘`

do

mkdir -p $Dst_Path/$dir

for file in `find $Src_Path/$dir/ -type f|awk -F ‘/‘ ‘{print $NF}‘`

do

tar -zcPvf $Dst_Path/$dir/$file.tar.gz $Src_Path/$dir/$file

done

done

  

shell脚本递归压缩实践

标签:log   dep   ash   done   shel   pre   awk   脚本   data   

原文地址:https://www.cnblogs.com/xzlive/p/9379386.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!