使用 awk 从文本文件中提取数据
Possible Duplicate:
Extract data between two points in a text file
For example:
Reply: [200/OK] bytes=29086 time=583ms
I would want to extract the value between "time=" and "ms"
Expected Result:
"583"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我会使用 sed 来实现这一点,但由于您要求 awk:
-F
定义了字段分隔符的扩展正则表达式。所以我们定义“time=”或“ms”分隔字段,然后打印第二个字段。使用 sed ,它将是:
I would use sed for that, but since you ask for awk:
The
-F
defines extended regexp for field separator. So we define that "time=" or "ms" separates the fields, and then print second field.using sed, it would be:
丑陋但有效:
或者没有 sed:
Ugly but works:
Or without
sed
:试试这个
我希望这有帮助。
PS,由于您似乎是新用户,如果您得到的答案对您有帮助,请记住将其标记为已接受,和/或给它 +(或 -)作为有用的答案。
Try this
I hope this helps.
P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.