GREP REGEX大文件 [英] GREP REGEX LARGE FILE
问题描述
在MAC上,我该如何GREP?我有一个大的TXT文件(200MB)。样本数据如下。我想用一个正则表达式运行一个GREP,并且能够在我的终端响应中获得以下数据值:
lockquote
00424730350000190100130JEAN DANIELE&
我希望一切高达 82700
。一旦获得这些信息,我可以将其复制到另一个文件中用于其他目的。现在我刚收到大量信息。
样本记录:
00424730350000190100130JEAN DANIELE& 82700 TINEPORK CT LAT BORAN AK 12345 3342843470224201400003980000002664300001216IWD QD0415200800004005880002281300000671IWD QM0330200500004900000001836800000431IWD QM0325199900002455270001147700000969IWD QM
样本Grep我写道:
grep -E^(。*?)82700MYFILE.TXT
grep -E^(。*?)[0-9]MYFILE .TXT
这仍然不起作用,它会返回吨信息和 82700
可以是任何值...我希望它是任何帮助建议?谢谢
对于示例数据
grep -E -o^ [0-9] {23} [^ 0-9] + [0-9] +MYFILE.TXT
似乎可以胜任这项工作:
00424730350000190100130JEAN DANIELE& 82700
使用 Darwin 14.4.0上的grep(BSD grep)2.5.1-FreeBSD 。
请评论,如果并且需要调整/进一步的细节。
On a MAC how do I GREP? I have a large TXT file (200MB). The sample data is below. I want to run a GREP with a regex and be able to get ONLY the following data values in my terminal response:
00424730350000190100130JEAN DANIELE &
I want everything up to 82700
. Once I have this information, I can copy it into another file for other purpose. Now I just get back tons of information.
Sample Record:
00424730350000190100130JEAN DANIELE & 82700 TINEPORK CT LAT BORAN AK 12345 3342843470224201400003980000002664300001216IWD QD0415200800004005880002281300000671IWD QM0330200500004900000001836800000431IWD QM0325199900002455270001147700000969IWD QM
sample Grep I wrote:
grep -E "^(.*?)82700" MYFILE.TXT
grep -E "^(.*?)[0-9]" MYFILE.TXT
This still doesn't work, it gives back tons of info and the 82700
can be any value...I would like it to be Any help suggestions? thank you
For the sample data
grep -E -o "^[0-9]{23}[^0-9]+[0-9]+" MYFILE.TXT
seems to do the job:
00424730350000190100130JEAN DANIELE & 82700
using grep (BSD grep) 2.5.1-FreeBSD on Darwin 14.4.0.
Please comment, if and as this requires adjustment / further detail.
这篇关于GREP REGEX大文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!