linux 增量复制不同文件到另一个文件夹

1、脚本说明:

linux 增量复制不同文件到另一个文件夹。

用法:sh copy.sh  源目录  目标目录

#!/bin/sh
if [ $# -ne 2 ]; then
echo "Usage:./incremental_copy.sh source_dir destination_dir"
exit 1
fi
 
source_dir=$1
destination_dir=$2
 
for file in $(1s $source_dir); do 
    if [ ! -f destination_dir/$file ]; then
        cp $source_dir/$file $destination_dir
        echo "copied $file to $destination_dir"
    fi
done
echo "Incremental copy complete'

 

posted @ 2023-03-27 10:12  听&夏  阅读(455)  评论(0编辑  收藏  举报