#!/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
原文地址:https://www.cnblogs.com/xzlive/p/9379386.html
时间: 2024-11-02 13:28:34