KEY_WORD=$1 if [ -z "${KEY_WORD}" ]; then echo'缺少关键词' fi
DIR=$2 if [ -z "${DIR}" ]; then echo'缺少目录' fi
IFS=' '
files=`find "${DIR}" -type f`
for file in${files}; do info=`grep -in"${KEY_WORD}""${file}"` if [ ${#info} -gt 0 ]; then echo"============================================" echo"file path: ${file}" echo"${info}" fi done echo"============================================"