JOIN(1)

๐Ÿ’– join โ€” okay bestie, let's talk

so the manual name is join (it lives in section 1, user commands, in case anyone asks) and it does exactly one iconic thing: it takes lines from two files and glues them together when they share a common field. that's it. that's the whole vibe. โœจ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

join [OPTION]... FILE1 FILE2

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so picture this: you've got two files, right? for every pair of input lines that have identical join fields, join writes a line out to standard output. and the default join field โ€” like, the one it uses if you don't say otherwise โ€” is the first field, and fields are delimited by blanks. easy. slay.

and here's a lil treat: if FILE1 or FILE2 (not both, bestie, pick one) is -, then it reads standard input. ๐Ÿซถ

now. the options. there are a lot of them and honestly they're all kind of iconic, so let's go:

  • -a FILENUM โ€” also print the unpairable lines from file FILENUM, where FILENUM is 1 or 2, matching up to FILE1 or FILE2. so like, the leftovers get to come to the party too ๐Ÿ’…
  • -e STRING โ€” replace missing (empty) input fields with STRING. i.e., the missing fields you specified with the '-12jo' options. no field left behind ๐Ÿ’–
  • -i, --ignore-case โ€” ignore differences in case when comparing fields. uppercase, lowercase, we don't care, we're chill like that โœจ
  • -j FIELD โ€” literally just equivalent to '-1 FIELD -2 FIELD'. a shortcut, a little timesaver, we love her
  • -o FORMAT โ€” obey FORMAT while constructing the output line. you're in charge of the fit now ๐Ÿ‘‘
  • -t CHAR โ€” use CHAR as the input and output field separator
  • -v FILENUM โ€” like -a FILENUM, but suppress the joined output lines. only the loners, none of the couples ๐Ÿ™ˆ
  • -1 FIELD โ€” join on this FIELD of file 1
  • -2 FIELD โ€” join on this FIELD of file 2
  • --check-order โ€” check that the input is correctly sorted, even if all input lines are pairable. it's doing a vibe check on your sort fr fr
  • --nocheck-order โ€” do not check that the input is correctly sorted. live your truth, no vibe check today
  • --header โ€” treat the first line in each file as field headers, print them without trying to pair them. respect the headers, they're the main characters ๐ŸŽ€
  • -z, --zero-terminated โ€” line delimiter is NUL, not newline
  • --help โ€” display this help and exit
  • --version โ€” output version information and exit

okay now the details, because this is where it gets real:

unless -t CHAR is given, leading blanks separate fields and are ignored. otherwise, fields are separated by CHAR. any FIELD is a field number counted from 1 (not 0, bestie, this isn't that kind of program).

FORMAT is one or more comma or blank separated specifications, and each one is either 'FILENUM.FIELD' or '0'. the default FORMAT outputs the join field, the remaining fields from FILE1, the remaining fields from FILE2, all separated by CHAR. and if FORMAT is the keyword 'auto', then the first line of each file determines the number of fields output for each line. cute, right? ๐ŸŒˆ

Important: FILE1 and FILE2 must be sorted on the join fields. this is not a suggestion, this is the law ๐Ÿ˜ญ for example, use "sort -k 1b,1" if join has no options, or use "join -t ''" if sort has no options. comparisons honor the rules specified by 'LC_COLLATE'. and if the input is not sorted and some lines cannot be joined, a warning message will be given. so like. sort your files. please. for me. ๐Ÿ’€

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Written by Mike Haertel. legend behavior, honestly.


๐Ÿ˜ญ REPORTING BUGS ๐Ÿ˜ญ

found something cursed? tell the people:


Copyright ยฉ 2026 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.

This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. (ngl that part is important, don't skip it ๐Ÿซถ)


๐ŸŒŸ SEE ALSO ๐ŸŒŸ


and that's the whole page, bestie ๐Ÿ’… this was GNU coreutils 9.12, dated September 2026 โ€” go forth and join your lines, and remember: sort first, slay always. ๐Ÿฆ‹โœจ

๐Ÿ“ฆ where this page comes from