Join Statement omitting entries

前端 未结 1 1816
-上瘾入骨i
-上瘾入骨i 2021-01-27 10:08

Using: Unix 2.6.18-194.el5

I am having an issue where this join statement is omitting values/indexes from the match. I found out the values are between 11-90 (out of abo

相关标签:
1条回答
  • 2021-01-27 11:08

    I tried this out, and I noticed a couple things.

    First: this is minor, but I think you're missing a comma in your -o specifier. I changed it to -o 1.1,2.1.

    But then, running it on just the fragments you posted, I got only three lines of output:

    1|1
    3|3
    7|7
    

    I think this is because join assumes alphabetical sorting, while your input files look like they're numerically sorted.

    Rule #1 of join(1) is to make sure your inputs are sorted, and the same way join expects them to be!

    When I ran the two input files through sort and then joined again, I got 18 rows of output. (Sorting was easy, since you're joining on the first column; I didn't have to muck around with sort's column specifiers.)

    Beware that, these days, sort doesn't always sort the way you expect, due to locale issues. I tend to set LC_ALL=C to make sure I get the old-fashioned behavior I'm used to.

    0 讨论(0)
提交回复
热议问题