grep 正则表达式位于行中间
我有一个如下所示的日志文件条目:
04/21 15:22:56 信息 [jrpp-42] - 执行数据库查询时出错。未找到存储过程“dbo.get_discount”。指定owner.objectname 或使用sp_help 检查该对象是否存在(sp_help 可能会产生大量输出)。
错误发生在第67行。包含或处理的文件的具体顺序是:/default.cfm ||位置 -- 10.8.79.7 ||浏览器-||查询字符串 -- sshealth=1 ||引用者 -
我正在尝试专门针对这部分进行 grep:
执行数据库查询时出错。未找到存储过程“dbo.get_discount”。
然而dbo之后的部分。是可变的。它并不总是 get_discount。我试图找到能够解释这一点的正则表达式,然后仍然包含“'未找到”字符串。
我可以分两部分完成此操作,但我想知道是否有可以使用的正则表达式。谢谢。
例如 grep “执行数据库查询时出错。未找到存储过程 'dbo.[REGEX]'。”文件名.log
I have a log file entry that looks like this:
04/21 15:22:56 Information [jrpp-42] - Error Executing Database Query. Stored procedure 'dbo.get_discount' not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).
The error occurred on line 67. The specific sequence of files included or processed is: /default.cfm || Location -- 10.8.79.7 || Browser -- || Querystring -- sshealth=1 || Referer --
I am trying to grep specifically for this part:
Error Executing Database Query. Stored procedure 'dbo.get_discount' not found.
However the part after dbo. is variable. It's not always get_discount. I'm trying to find the regex expression that will account for that and then still include the "' not found" string.
I can do this in two parts but I'm wondering if there is a regular expression that would work. Thanks.
e.g grep "Error Executing Database Query. Stored procedure 'dbo.[REGEX]' not found." filename.log
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
grep
或使用awk
。使用awk
,您可以在找到字符串后进行编程。You can use
grep
or you can useawk
. Withawk
you have the advantage to do programming upon finding your string.