去除重复关键字

#!/bin/sh
########################################
# Fuction: delete the duplicate keyworld
#          from the file
# History: xulei First release
#
########################################

KEYWORLDS=`cat log.txt | egrep --color --only-matching "PG[0-9]{5}"`
KEYFILE=/tmp/keyworld.txt

cat /dev/null > ${KEYFILE}
for i in ${KEYWORLDS}
do
        cat ${KEYFILE} | grep $i
        if [[ "$?" != "0" ]];then
        {
                echo $i >> ${KEYFILE}
        }
        fi
done

你可能感兴趣的:(去除重复关键字)