我想在这里替换“cat”,以便源中的行项目可以有空格,以使这个 Rsync 脚本更便携(在 OSX 中)。
各位高手能不能给点建议的方法呢?其他改善这一点的建议也很感激!谢谢!
担
#!/bin/bash
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH
LOG="/Users/jdoe/Desktop/rsync-`/bin/date +%m%d%Y`.log"
EXCLUDE="/tmp/exclude.dat"
{
echo "-----------------------------------------------"
echo "Start:" $0
echo "-----------------------------------------------"
date "+%a %m-%d-%y %H:%M:%S"
echo "-----------------------------------------------"
options="-aNHxEh --delete --fileflags --exclude-from=$EXCLUDE --delete-excluded --force-change --progress --stats --protect-args"
destin='/Users/jdoe/Desktop/DEST/'
for source in $(cat /tmp/list.dat)
do
echo "Source: " $source
echo "Destination: " $destin
echo "rsync" $options $source $destin
/opt/local/bin/rsync $options $source $destin
retcode=$?
if [ $retcode -gt 0 ]
then
echo "ERROR: rsync " $source "failed with code " $retcode
fi
echo "-----------------------------------------------"
date "+%a %m-%d-%y %H:%M:%S"
echo "-----------------------------------------------"
done
echo "-----------------------------------------------"
echo "End:" $0
echo "-----------------------------------------------"
} >> $LOG 2>&1
exit 0