AIX join command

Homepage Clovertech Forums Read Only Archives Cloverleaf General AIX join command

  • Creator
    Topic
  • #51334
    David Teh
    Participant

    Hi guys,

    Trying to get something to work here with the unix join command.

    I have an IN.dat file (1st column is MSG ID and 2nd column is UNIX TIME):

    6839944 1251732690

    6839945 1251732709

    6839946 1251732722

    6839947 1251732722

    6839948 1251732735

    (etc)

    I have an OUT.dat file:

    6958611 1246807903

    6958612 1246808006

    6958613 1246808090

    6958614 1246808115

    6958615 1246808259

    6958616 1246808337

    6958617 1246808434

    6958618 1246808548

    The records in the 2 files may not necessary match.

    I basically want 4 columns in a 3rd file as shown:

    “IN MSG ID”  “IN TIME” “OUT MSG ID” “OUT TIME”     [if matching]

    (none) (none) “OUT MSG ID” “OUT TIME”     [if not matching]

    “IN MSG ID”  “IN TIME” (none) (none)      [if not matching]

    The following command seems to have worked for others but not me:

    join -t “,” -a 1 -a 2 -e ‘(none)’ -o 0,1.2,2.2 IN.dat OUT.dat

    Output I got:

    6839944 1251732690,(none),(none)

    6839945 1251732709,(none),(none)

    6839946 1251732722,(none),(none)

    6839947 1251732722,(none),(none)

    6839948 1251732735,(none),(none)

    6839949 1251732783,(none),(none)

    6839950 1251732783,(none),(none)

    6839951 1251732802,(none),(none)

    6839952 1251732833,(none),(none)

    6839953 1251732881,(none),(none)

    6839954 1251732894,(none),(none)

    6839955 1251732925,(none),(none)

    6839956 1251732979,(none),(none)

    6839957 1251733009,(none),(none)

    “6839944 1251732690” (no comman??) seem to suggest that the command treats it as a single field instead of 2 fields?

    Any idea what’s wrong?

    TIA!

Viewing 2 reply threads
  • Author
    Replies
    • #69762
      Abe Rastkar
      Participant

      It seems like since you used a comma as the field separator, it picked up both fields as one. the -t represents a separator in the input and the output files. The following is from the man page

      -t Character  Uses the character specified by the Character parameter as the field separator character in the input and the output. Every appearance of the character in a line is significant. The default separator is a space. With default field separation, the collating sequence is that of the sort -b command. If you specify -t, the sequence is that of a plain sort. To specify a tab character, enclose it in single quotation marks.

    • #69763
      David Teh
      Participant

      thought -t was for the resulting output…let me test it out first…

      thanks!

      Abe Rastkar wrote:

      It seems like since you used a comma as the field separator, it picked up both fields as one. the -t represents a separator in the input and the output files. The following is from the man page

      -t Character

    • #69764
      David Teh
      Participant

      reporting back…….

      “problem” with join is that you need to do a sort on both files first on the key column…..

Viewing 2 reply threads
  • The forum ‘General’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,126
Forums
28
Topics
9,296
Replies
34,439
Topic Tags
287
Empty Topic Tags
10