【发布时间】:2011-03-01 19:22:45
【问题描述】:
Grep 的行为会有所不同,具体取决于我在正则表达式周围使用的引号类型。我似乎无法清楚地理解为什么会这样。这是一个问题的例子:
hamiltont$ grep -e show\( test.txt
variable.show();
variable.show(a);
variable.show(abc, 132);
variableshow();
hamiltont$ grep -e "show\(" test.txt
grep: Unmatched ( or \(
hamiltont$ grep -e 'show\(' test.txt
grep: Unmatched ( or \(
我只是假设有一些适当的方法可以用单/双引号将正则表达式括起来。有什么帮助吗?
FWIW,grep --version 返回grep (GNU grep) 2.5.1
【问题讨论】: