我原以为我会这个(至少知道如何通过谷歌搜寻)!
但是当我在文本文件中搜索模式时,我无法弄清楚如何使用grep匹配双引号。我尝试用反斜杠转义双引号符号,但似乎不起作用。
>cat trial.txt
"Bill" is here and "Ben" is there
> grep -iE "and \"ben\" is" trial.txt
Unmatched ".
我该如何让这个工作起来?
我原以为我会这个(至少知道如何通过谷歌搜寻)!
但是当我在文本文件中搜索模式时,我无法弄清楚如何使用grep匹配双引号。我尝试用反斜杠转义双引号符号,但似乎不起作用。
>cat trial.txt
"Bill" is here and "Ben" is there
> grep -iE "and \"ben\" is" trial.txt
Unmatched ".
我该如何让这个工作起来?
使用单引号考虑每个字符的字面含义。
grep 'and "Ben" is' trial.txt