有了文献列表如何新增不重复的文献: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'
生成的.x文件可以一次性删除,这是我如此命名的理由:
rm *.x