Combining two very large files ignoring the first sentence

耗尽温柔 提交于 2020-01-15 07:16:40

问题


I want to combine two giant file each few hundred megabyte into a single file while ignoring the first line.

I wanted to use awk as I thought it should be the most optimized way. the way I'm doing it only ignores the first line of second file. Any idea how to do make work or if there's a faster way to do it?

awk 'FNR!=NR && FNR==1 {next} 1' 'FNR!=NR && FNR==1 {next} 2' s_mep_{1,2}.out >> s_mep.out

回答1:


$ awk 'FNR>1' file{1,2} > file_12



回答2:


With sed

(sed '1d' file_1 ; sed '1d' file_2) > new_file



回答3:


Generalizing to arbitrarily many files ...

for f in ... ; do
  tail -n +2 "$f" >> well_chosen_filename
done


来源:https://stackoverflow.com/questions/52939685/combining-two-very-large-files-ignoring-the-first-sentence

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!