3 ms·
Even as a decades long 'nix user, I had never used join until recently, which joins lines of two files on a common field. I used to turn to fgrep or a Python sc
by cybersol 9y ago
Even as a decades long 'nix user, I had never used join until recently, which joins lines of two files on a common field. I used to turn to fgrep or a Python script to solve a whole class of problems join can help solve on the command-line.
- minhajuddin 9y agoI recently got to use `join`. However, without reading documentation on outer joins. I went ahead and wrote my own version: join -t$'\t' <(cat c <(comm -13 <(cut -f1 c) <(cut -f1 d) | sed -e 's/$/\t/') | sort -k1,1) <(cat d <(comm -23 <(cut -f1 c) <(cut -f1 d) | sed -e 's/$/\t/') | sort -k1,1) Then I stumbled on an easier version with using just join join -a1 -a2 -o auto f1 f2 There are really too many unexplored things on the linux command line for a typical dev.