grep 中的正则表达式 - bash 拾取字符串

发布于 2024-12-26 02:36:13 字数 560 浏览 0 评论 0原文

我正在尝试运行此命令

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

但是当我按 Enter 时,它会转到此:

>

指示我有一个开放报价。有人可以帮忙吗?

谢谢

I'm trying to run this

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

but I keep getting this error

-sh: syntax error near unexpected token `('

I've tried escaping all the brackets like this:

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

But when I hit enter, it then goes to this:

>

Indicating that I have an open quote. Can anyone assist here?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浊酒尽余欢 2025-01-02 02:36:13

这个怎么样——

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

How about this one -

grep -R -l --exclude-dir=merchant --exclude-dir=newport '(\w*)\.execute\("ATTACH DATABASE '/include/location\.db' AS (\w*)"\);'  * | wc -l
对你而言 2025-01-02 02:36:13

引用整个内容并转义内部引号怎么样:

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

How about quoting that whole thing and escaping the internal quotes:

grep -R -l --exclude-dir=merchant --exclude-dir=newport "(\w*)\.execute\(\"ATTACH DATABASE '/include/location\.db' AS (\w*)\"\);"  * | wc -l
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文