3
私はbashで簡単な留守番電話を作った。基本的に挨拶すると、挨拶しますが、文章解析に問題があります。 文($ @)が複数の単語である場合、それは失敗します。ファイルからBash、grep文
if [[ "[email protected]" = $(grep -Fx "[email protected]" 'vocabulary/greeting') ]]
then
speak greeting
elif [[ "[email protected]" = $(grep -Fx "[email protected]" 'vocabulary/appreciative') ]]
出力:私はこの問題を解決するにはどうすればよい
> hello
Sam: Hi!
> how are you
grep: are: No such file or directory
grep: you: No such file or directory
grep: are: No such file or directory
grep: you: No such file or directory
grep: are: No such file or directory
grep: you: No such file or directory
grep: are: No such file or directory
grep: you: No such file or directory
grep: are: No such file or directory
grep: you: No such file or directory
Sam: I don't understand.
>
? 今後どのようにこれらのエラーが発生する可能性がありますか?
これはOPで機能する可能性がありますが、この方法ではすべての空白を1つのスペースに呑み込むことに注意してください。ですから、./script Howはです。あなたは './scriptになるでしょうかはです。おそらく、それは簡単にgrepするために、OPが望んでいるものです。 –
anishsane