首页 > 代码库 > shell 检查一个单词是否在字典中

shell 检查一个单词是否在字典中

#!/bin/bash
#文件名:checkword.sh
word=$1
grep "^$1$" /usr/share/dict/linux.words -q
if [ $? -eq 0 ];
then
echo $word is a dictionary word;
else
echo $word is not a dictionary word;
fi