#! /bin/bash
path=$1
#source directory topath=$2 #target directory
find ${path} -name "*" -type f -size 0c | xargs -n 1 rm -f
if [ ! -d "$topath" ]
then
mkdir -p "$topath"
fi
while(true)
do
for file in ls $path
do
yes|cp ${path}/${file} ${topath}/${file}
sleep 3s
done
sleep 3s
done
====================================================================
Copy a file to the target directory every 3 seconds
start up
shell source directory target directory
find ${path} -name "*" -type f -size 0c | xargs -n 1 rm -f
Use find to query files with empty file sizes in the source directory and delete
if [! -d "$topath"]
then
mkdir -p "$topath"
fi
Determine whether the target directory exists, create it if it does not exist
yes|cp ${path}/${file} ${topath}/${file}
Force copy the files in the source directory to the target directory