本文介绍了提取文本文件中两点之间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在文本文件的两点之间提取数据?
How would it be possible to extract data between two points in a text file?
例如
Reply: [200/OK] bytes=29086 time=583ms
"time =和"ms"之间的值
The value between "time=" and "ms"
推荐答案
sed -n 's/.*time=\(.*\)ms/\1/p' < logfile
这将设置一个正则表达式,将time=
和ms
之间的所有内容捕获到第一个捕获组(在右侧称为\1
)中并将其打印.
This sets up a regular expression that captures everything between the time=
and ms
into the first capture group (which is referred to on the right-hand-side as \1
) and prints it.
这篇关于提取文本文件中两点之间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!