这是我的备份脚本,我有一个问题。 我想要。有重复文件时不要播放MV。 然后我希望脚本转到下一个。
#!/bin/sh
LocalLogMoveDATA=$(exec date -d -1days '+%Y%m%d')
DATAlist="AA BB CC DD EE FF"
for DATAdir in $DATAlist
do
if [ -e "/Tick/$DATAdir/$LocalLogMoveDATA" ]
then
rm -rf /apple/super/mail/rec/data/$DATAdir/$LocalLogMoveDATA
else
mv /apple/super/mail/rec/data/$DATAdir/$LocalLogMoveDATA /Tick/$DATAdir/
fi
done
答案 0 :(得分:0)
如果您的意思是“请勿mv
如果目的地中已存在同名文件”,则-n
选项会执行此操作。
您的脚本还存在其他一些风格问题。请参阅内联评论。
#!/bin/sh
# exec did nothing useful here
LocalLogMoveDATA=$(date -d -1days '+%Y%m%d')
# keeping the directory names in a variable didn't seem to serve any purpose
for DATAdir in AA BB CC DD EE FF
do
# add a variable to keep this in one place
datadir=/apple/super/mail/rec/data/$DATAdir/$LocalLogMoveDATA
# fix indentation of the loop body
if [ -e "/Tick/$DATAdir/$LocalLogMoveDATA" ]
then
# add missing quotes
rm -rf "$datadir"
else
# ditto, and add -n option
mv -n "$datadir" "/Tick/$DATAdir/"
fi
done