小编Eug*_*eck的帖子

逐步浏览大文件

我有几个大型数据文件(约100MB-1GB的文本)和一个数万个时间戳的排序列表,它们索引感兴趣的数据点.时间戳文件如下所示:

12345
15467
67256
182387
199364
...
Run Code Online (Sandbox Code Playgroud)

数据文件如下所示:

Line of text
12345 0.234 0.123 2.321
More text
Some unimportant data
14509 0.987 0.543 3.600
More text
15467 0.678 0.345 4.431
Run Code Online (Sandbox Code Playgroud)

第二个文件中的数据全部按时间戳排列.我想使用第一个文件的时间戳来浏览第二个文件,在输出文件中打印时间戳和第四个数据项.我一直在用这个:

grep -wf time.stamps data.file | awk '{print $1 "\t" $4 }'  >> output.file
Run Code Online (Sandbox Code Playgroud)

对于每个数据文件,这需要一天的顺序.问题是这个命令搜索整个数据文件中的每一行time.stamps,但我只需要搜索从最后一个数据点获取.有没有办法加快这个过程?

unix shell grep

5
推荐指数
1
解决办法
124
查看次数

标签 统计

grep ×1

shell ×1

unix ×1