Skip to main content
10 events
when toggle format what by license comment
Aug 13, 2015 at 16:36 comment added anurag Awk script worked perfectly for me. Thanks :)
Aug 12, 2015 at 12:05 comment added glenn jackman So storing all of file2 in memory is trivial.
Aug 12, 2015 at 10:32 comment added anurag file2 is having nearly 40-50 records...but file1 is having 3Million records
Aug 12, 2015 at 0:44 comment added Peter Cordes No clue, have to ask @anurag, since he's the one that wrote that his files are "huge". But yes, it's basically fine unless it start paging out your GUI desktop. And potentially faster to sequential-read one file and then the other, rather than generating seeks back and forth.
Aug 12, 2015 at 0:34 comment added glenn jackman @PeterCordes: define "huge": is file2 measured in GB?
Aug 12, 2015 at 0:33 comment added glenn jackman @jimmij, sure, but you don't really need to do that assignment for every line in file1
Aug 11, 2015 at 19:17 comment added Peter Cordes The files are "huge", so it might be better to use awk's getline f2 <file2 to read both files in parallel. If you can get awk to start from the beginning of a file again, when it hits the end...
Aug 11, 2015 at 19:08 comment added jimmij You can join two last awk actions (lines) into one: awk -v OFS=, 'NR==FNR{size2++; file2[FNR]=$0; next}{file2[0]=file2[size2]; print $0, file2[FNR%size2]}' file2 file1
Aug 11, 2015 at 17:21 history edited glenn jackman CC BY-SA 3.0
added 396 characters in body
Aug 11, 2015 at 17:14 history answered glenn jackman CC BY-SA 3.0