Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • can there be more than 3 numbers in a line in second file? Commented Oct 6, 2016 at 5:39
  • also, seems like 1st/2nd column numbers are sorted both row wise and column wise, is that always true? Commented Oct 6, 2016 at 5:46
  • If the real data is huge, I'd consider using at least a small perl script instead of awk/cut (because traversing file 2 each time is slow and makes it quadratic), and if it's really huge, I'd write a C program. It's also important to have an idea how large these numbers can get, especially those in file 2. Commented Oct 6, 2016 at 6:58
  • @dirkt I don't think that perl can be faster than awk, see benchmarks in my answer. Commented Oct 6, 2016 at 11:26
  • @rudimeier, agree awk is usually faster than perl, but I feel like someone with better experience would be able to write a perl solution much faster than mine :) Commented Oct 6, 2016 at 11:37