Skip to main content
added 97 characters in body
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

Assuming the files are all sorted and that we're using a shell that understands process substitutions (like bash):

$ join -t . -v 1 -o 0 <( join -t . a.txt b.txt ) c.txt
c

or, for other shells,

$ join -t . a.txt b.txt | join -t . -v 1 -o 0 - c.txt
c

This uses join twice to perform relational joins between the files. The data is interpreted as dot-delimited fields (with -t .).

The join between a.txt and b.txt is straight forward and produces

a.up
b.up
c.up

These are all the lines from the two files whose first dot-delimited field occurs in both files. The output consists of the join field (a, b, c) followed by the other fields from both files (only b.txt has any further data).

The second join is a bit more special. With -v 1 we ask to see the entries in the first file (the intermediate result above) that can't be paired with any line in the second file, c.txt. Additionally, we only ask to see the join field itself (-o 0). Without the -o flag, we would get c.up as the result.


If the files are not sorted, then each occurance of a filename file could be replaced by <( sort file ) in the command.

Assuming the files are all sorted and that we're using a shell that understands process substitutions (like bash):

$ join -t . -v 1 -o 0 <( join -t . a.txt b.txt ) c.txt
c

This uses join twice to perform relational joins between the files. The data is interpreted as dot-delimited fields (with -t .).

The join between a.txt and b.txt is straight forward and produces

a.up
b.up
c.up

These are all the lines from the two files whose first dot-delimited field occurs in both files. The output consists of the join field (a, b, c) followed by the other fields from both files (only b.txt has any further data).

The second join is a bit more special. With -v 1 we ask to see the entries in the first file (the intermediate result above) that can't be paired with any line in the second file, c.txt. Additionally, we only ask to see the join field itself (-o 0). Without the -o flag, we would get c.up as the result.


If the files are not sorted, then each occurance of a filename file could be replaced by <( sort file ) in the command.

Assuming the files are all sorted and that we're using a shell that understands process substitutions (like bash):

$ join -t . -v 1 -o 0 <( join -t . a.txt b.txt ) c.txt
c

or, for other shells,

$ join -t . a.txt b.txt | join -t . -v 1 -o 0 - c.txt
c

This uses join twice to perform relational joins between the files. The data is interpreted as dot-delimited fields (with -t .).

The join between a.txt and b.txt is straight forward and produces

a.up
b.up
c.up

These are all the lines from the two files whose first dot-delimited field occurs in both files. The output consists of the join field (a, b, c) followed by the other fields from both files (only b.txt has any further data).

The second join is a bit more special. With -v 1 we ask to see the entries in the first file (the intermediate result above) that can't be paired with any line in the second file, c.txt. Additionally, we only ask to see the join field itself (-o 0). Without the -o flag, we would get c.up as the result.


If the files are not sorted, then each occurance of a filename file could be replaced by <( sort file ) in the command.

added 119 characters in body
Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

Assuming the files are all sorted and that we're using a shell that understands process substitutions (like bash):

$ join -t . -v 1 -o 0 <( join -t . a.txt b.txt ) c.txt
c

This uses join twice to perform relational joins between the files. The data is interpreted as dot-delimited fields (with -t .).

The join between a.txt and b.txt is straight forward and produces

a.up
b.up
c.up

These are all the lines from the two files whose first dot-delimited field occurs in both files. The output consists of the join field (a, b, c) followed by the other fields from both files (only b.txt has any further data).

The second join is a bit more special. With -v 1 we ask to see the entries in the first file (the intermediate result above) that can't be paired with any line in the second file, c.txt. Additionally, we only ask to see the join field itself (-o 0). Without the -o flag, we would get c.up as the result.


If the files are not sorted, then each occurance of a filename file could be replaced by <( sort file ) in the command.

Assuming the files are all sorted and that we're using a shell that understands process substitutions (like bash):

$ join -t . -v 1 -o 0 <( join -t . a.txt b.txt ) c.txt
c

This uses join twice to perform relational joins between the files. The data is interpreted as dot-delimited fields (with -t .).

The join between a.txt and b.txt is straight forward and produces

a.up
b.up
c.up

These are all the lines from the two files whose first dot-delimited field occurs in both files. The output consists of the join field (a, b, c) followed by the other fields from both files (only b.txt has any further data).

The second join is a bit more special. With -v 1 we ask to see the entries in the first file (the intermediate result above) that can't be paired with any line in the second file, c.txt. Additionally, we only ask to see the join field itself (-o 0). Without the -o flag, we would get c.up as the result.

Assuming the files are all sorted and that we're using a shell that understands process substitutions (like bash):

$ join -t . -v 1 -o 0 <( join -t . a.txt b.txt ) c.txt
c

This uses join twice to perform relational joins between the files. The data is interpreted as dot-delimited fields (with -t .).

The join between a.txt and b.txt is straight forward and produces

a.up
b.up
c.up

These are all the lines from the two files whose first dot-delimited field occurs in both files. The output consists of the join field (a, b, c) followed by the other fields from both files (only b.txt has any further data).

The second join is a bit more special. With -v 1 we ask to see the entries in the first file (the intermediate result above) that can't be paired with any line in the second file, c.txt. Additionally, we only ask to see the join field itself (-o 0). Without the -o flag, we would get c.up as the result.


If the files are not sorted, then each occurance of a filename file could be replaced by <( sort file ) in the command.

Source Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

Assuming the files are all sorted and that we're using a shell that understands process substitutions (like bash):

$ join -t . -v 1 -o 0 <( join -t . a.txt b.txt ) c.txt
c

This uses join twice to perform relational joins between the files. The data is interpreted as dot-delimited fields (with -t .).

The join between a.txt and b.txt is straight forward and produces

a.up
b.up
c.up

These are all the lines from the two files whose first dot-delimited field occurs in both files. The output consists of the join field (a, b, c) followed by the other fields from both files (only b.txt has any further data).

The second join is a bit more special. With -v 1 we ask to see the entries in the first file (the intermediate result above) that can't be paired with any line in the second file, c.txt. Additionally, we only ask to see the join field itself (-o 0). Without the -o flag, we would get c.up as the result.