我有一個腳本來檢查傳輸文件在運行之前,但即使我知道傳輸文件的事實,它也會運行。看起來'cmp'操作無法正常工作。我需要確保在完成傳輸之前我不抓取任何文件。代碼如下:使用cmp檢查傳輸文件不能正常工作
different=1
compare1=~/Desktop/$$-testing1.txt
compare2=~/Desktop/$$-testing2.txt
waittime=10s
DATE=$(date +%Y%m%d)
PRO="/Volumes/pubfiles/ConversionRequests/Processed"
DATEI=$(date +-%m-%d-%Y)
cd $PRO/Processed$DATEI
echo Checking if files are in process in ${PWD}...
while [ $different -eq 1 ]; do
ls [email protected] 1> $compare1
sleep $waittime
ls [email protected] 1> $compare2
if cmp $compare1 $compare2 ; then
echo Files have not changed in $waittime. Continuing...
different=0
else
echo Files are still being transferred. Waiting $waittime...
fi
done
rm $compare1
rm $compare2