RegEx中的grep - bash拾取字符串

时间:2012-01-12 03:59:55

标签: bash

我正在尝试运行此

grep -R -l --exclude-dir=merchant --exclude-dir=newport (\w*)\.execute\("ATTACH DATABASE '/include/location\.db' AS (\w*)"\);  * | wc -l

但我一直收到此错误

-sh: syntax error near unexpected token `('

我尝试过这样的括号:

grep -R -l --exclude-dir=merchant --exclude-dir=newport '"\(\w*\)\.execute\("ATTACH DATABASE \'/include/location\.db\' AS \(\w*\)"\);'  *.esp

但是当我点击进入时,它会转到:

>

表示我有一个公开的报价。任何人都可以在这里协助吗?

由于

2 个答案:

答案 0 :(得分:1)

如何引用整个内容并转义内部引号:

grep -R -l --exclude-dir=merchant --exclude-dir=newport "(\w*)\.execute\(\"ATTACH DATABASE '/include/location\.db' AS (\w*)\"\);"  * | wc -l

答案 1 :(得分:1)

这个怎么样 -

grep -R -l --exclude-dir=merchant --exclude-dir=newport '(\w*)\.execute\("ATTACH DATABASE '/include/location\.db' AS (\w*)"\);'  * | wc -l