这是我的问题,我已经在这个 shell 脚本上工作了一段时间,但我不知道我做错了什么。shell 脚本会给出错误,例如grep:textfile1.txt no such file or directory
和line 10 syntax error 'else'
。我不确定什么语法去哪里。这是我的脚本。
#!/bin/bash
echo "Find The file you want to search the word in"
read filename
cd ~ $filename
echo "enter the word you want to find"
read word1
grep -F "$word1" "$filename"
if $word exists in $filename then
echo "$word exist in $filename"
else
echo "the file or word doesn't exist!"