记得以前mayi兄写过,用C写的,我这个是用shell写的,大家看看有什么问题
主要用于清除.DIR文件中没有而在该板目录下依然存在的文件
#!/bin/sh
# Enter the boards directory
cd /export/bbshome/bbs2000/boards
# List all dirs in that directory
BOARDS=`ls`
# Enter each dirs
for dirs in $BOARDS
do
[ -d $dirs ] || continue
cd $dirs
# echo "Enter dir $dirs"
# Find files to check
# Find files to check
ls M\.*\.A | sort > _TMP_FILE_IN_DIR_
strings .DIR | grep "^M\.[0-9]" | grep "[0-9]\.A$" | sort >
_TMP_FILE_DOT_DIR_
diff _TMP_FILE_IN_DIR_ _TMP_FILE_DOT_DIR_ | grep "^< " | sed 's/^<
//' > _FILE_DIFF_
for file in `cat _FILE_DIFF_`
do
# echo "rm $file"
rm $file
done
rm -f _TMP_FILE_IN_DIR_ _TMP_FILE_DOT_DIR_ _FILE_DIFF_
cd ..
done
--
FROM ELM.neu.edu.cn