【发布时间】:2016-05-27 08:50:39
【问题描述】:
当用户输入内容时,脚本会检查输入是否包含 wordfile 中的任何单词。
输入:
A sentence that contains the word, word1.
字文件:
word1
word2
word3
代码:
[[ -z $(cat 'vocabulary/lists/wordfile' | grep -Fe $($input//" "/"\|")) ]]
输出:
> [WORD]
./core.sh: line 168: [WORD]// /\|: No such file or directory
grep: option requires an argument -- 'e'
Usage: grep [OPTION]... PATTERN [FILE]...
Try 'grep --help' for more information.
[WORD]
【问题讨论】:
-
您的
wordfile是什么样的?我认为这可能就像grep -Fqf wordfile <<<"$input" && echo 'found a word'一样简单。