如何使用grep查找用户输入的文件中的确切单词?例如,我需要选择要查找的单词和要在其中查找它的文件。我被告知我已经非常接近了,但是有些东西没有像应该的那样工作。我正在Linux下使用bash shell。
到目前为止,我所做的是:
#!/bin/bash
echo "Find the file you want to search the word in?"
read filename
echo "Enter the word you want to find."
read word1
grep $word1 $filename