notcont.sh
#################################################
#input: 精査対象ファイル、検索ワードファイル
#output: 精査対象ファイルに含まれない検索ワード
#param check: あり
#useage: notcont DATA_LIST_FILE SEARCH_LIST_FILE
#################################################
notcont()
(
#パラメータの個数チェック
if [ $# -ne 2 ]
then
echo "[ERROR] useage: notcont DATA_LIST_FILE SEARCH_LIST_FILE" 1>&2
return 1
fi
#ファイルの存在チェック
for _VAR in $*
do
if [ ! -r $_VAR ]
then
echo "[ERROR] $_VAR is not readable." 1>&2
return 1
fi
done
_notcont $*
)
#################################################
#input: 精査対象ファイル、検索ワードファイル
#output: 精査対象ファイルに含まれない検索ワード
#param check: なし
#useage: _notcont DATA_LIST_FILE SEARCH_LIST_FILE
#################################################
_notcont()
(
_DATA_LIST_FILE=$1
_SEARCH_LIST_FILE=$2
_DATA_LIST=`cat $_DATA_LIST_FILE | sort | uniq`
for _SEARCH_STR in `cat $_SEARCH_LIST_FILE`
do
if [ `printf "%s\n" $_DATA_LIST | grep $_SEARCH_STR | wc -l` -lt 1 ]
then
echo $_SEARCH_STR
fi
done
)
使用例
#関数読み込み
. ./notcont.sh
#実行
notcont data_list.txt search_list.txt