
Show HN: awk commands for `union`, `intersect`, `except`, `extra` - jph
I&#x27;m munging text and I wrote these awk commands that may be useful to other coders. Feedback welcome.<p>union (https:&#x2F;&#x2F;github.com&#x2F;sixarm&#x2F;union): print lines in (A union B)<p>intersect (https:&#x2F;&#x2F;github.com&#x2F;sixarm&#x2F;intersect): print lines in (A intersect B)<p>except (https:&#x2F;&#x2F;github.com&#x2F;sixarm&#x2F;except): print lines in (A 
except B) a.k.a. (A - B)<p>extra (https:&#x2F;&#x2F;github.com&#x2F;sixarm&#x2F;extra) : print lines in (A extra B) a.k.a. (B - A)<p>Examples:<p><pre><code>    $ 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</code></pre>
======
jph
Links:

* [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)

