Because the input to join
must be sorted, often the command is called similarly to:
join <(sort file1) <(sort file2)
This is not portable as it uses process substitution, which is not specified by POSIX.
join
can also use the standard input by specifying -
as one of the file arguments. However, this only allows for sorting one of the files through a pipeline:
sort file1 | join - <(sort file2)
It seems there should be a simple way to accomplish sorting of both files and then joining the results using POSIX-specified features only. Perhaps something using redirection to a third file descriptor, or perhaps it will require created a FIFO. However, I'm having trouble visualizing it.
How can join
be used POSIXly on unsorted files?