New documents in linux shell are not repeated

How to add non-duplicated documents with the document list: linux

#!bin/bash
n=1
#转换大小写
tr "[:upper:]" "[:lower:]" < add > add.x
while read line
do
echo -e "$n\t$line" >> log.x
#查找文献并储存记录
grep "$line" ./sorted >> log.x
#判断是否存在新文献
grep "$line" ./sorted > pare.x
if [ -s ./pare.x ] ; then 
	echo "$n exist"
else
	echo "$n empty!"
	echo -e "$n\t$line" >> empty.x
	echo -e "$line\taddnew" >> sorted
#添加新文献至原记录
fi
((n++))
done<'add.x'

The generated .x file can be deleted at one time. This is the reason I named it like this:
rm *.x

Guess you like

Origin blog.csdn.net/mushroom234/article/details/109057304