4 ms·
Show HN: awk commands for `union`, `intersect`, `except`, `extra`
I'm munging text and I wrote these awk commands that may be useful to other coders. Feedback welcome.
union (https://github.com/sixarm/union): print lines in (A union B)
intersect (https://github.com/sixarm/intersect): print lines in (A intersect B)
except (https://github.com/sixarm/except): print lines in (A
except B) a.k.a. (A - B)
extra (https://github.com/sixarm/extra) : print lines in (A extra B) a.k.a. (B - A)
Examples:
$ cat 1.txt
alpha
bravo
$ cat 2.txt
alpha
charlie
$ union 1.txt 2.txt
alpha
bravo
charlie
$ intersect 1.txt 2.txt
alpha
$ except 1.txt 2.txt
bravo
$ extra 1.txt 2.txt
charlie
- jph 10y agoLinks: * https://github.com/sixarm/union https://github.com/sixarm/union * https://github.com/sixarm/intersect https://github.com/sixarm/intersect * https://github.com/sixarm/except https://github.com/sixarm/except * https://github.com/sixarm/extra https://github.com/sixarm/extra