循环遍历文件,找出未配置的文件
背景:若干文件,list和dat一一对应,现在dat多了,不知道少哪些list
代码:
#!/bin/bash
echo -e "list不存在的dat文件\n" >>noExist.txt
for file in $1/*.dat
do
if test -f $file
then
NUM=`grep -w ${file##*/} $2/*.list |wc -l`
if [ "0" -eq ${NUM} ]
then
echo $file
echo -e $file >>noExist.txt
fi
fi
done
结果: