我以为我知道这一点(或者至少知道如何用谷歌搜索它)!
但是在文本文件中搜索模式时,我无法弄清楚如何使用 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
关于regex - 如何使用grep匹配双引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38996609/