Forrest logo
back to the join tool

join:tldr:331f9

join: Join field3 of file1 with field1 of file2.
$ join -1 ${3} -2 ${1} ${file1} ${file2}
try on your machine

The join command is used to join lines of two files based on a common field. Here is an explanation of the provided command:

  • join: This is the command itself, used to join lines from two files.
  • -1 ${3}: This specifies the field number (column) in the first file to be used for joining. In this case, it refers to the third field in the first file. ${3} indicates that the value is taken from the third positional parameter passed to the script or command.
  • -2 ${1}: This specifies the field number (column) in the second file to be used for joining. In this case, it refers to the first field in the second file. ${1} indicates that the value is taken from the first positional parameter passed to the script or command.
  • ${file1}: This is the first file to be joined. ${file1} indicates that the value is taken from the positional parameter passed to the script or command.
  • ${file2}: This is the second file to be joined. ${file2} indicates that the value is taken from another positional parameter passed to the script or command.

Overall, the command is used to join lines from ${file1} and ${file2} based on the third field of ${file1} and the first field of ${file2}. The resulting lines will contain fields from both files, with a common field (as specified) for the join.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the join tool