↑ ↓ select, Enter open, Esc close

Join two files on a common field

Adjust the values, the command updates live
user@server
join -t ';' <(sort -t ';' -k1,1 domains-customers.csv) <(sort -t ';' -k1,1 domains-expiry.csv)

Sorts both files by the first field and prints a combined line for every key that appears in both. In the example, a list of domains to customers and a list of domains to expiry dates become one combined list. Lines without a partner are dropped, with -a 1 those of the first file are kept.

Note: join requires correctly sorted input, hence the sorting via process substitution <(...), which requires Bash.

Also searched as

  • join two csv files on key linux
  • merge lists by common field
  • sql join on the command line

Related one-liners

All in Text processing

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.