This week I’ve published an Awk script for sorting unique columns from a list of files. Check the documentation for detailed getting started and usage instructions, the source code is available on GitHub. What follows is the TLDR for installation and usage…

Quick Start

Clone

mkdir -vp ~/git/hub/awk-utilities

cd ~/git/hub/awk-utilities

git clone git@github.com:awk-utilities/column-uniquely-sorted.git

Install

Project script(s) and manual page(s) may be installed via make install command…

cd ~/git/hub/awk-utilities/column-uniquely-sorted

make install

Uninstall

Script(s) and manual page(s) for this project may be uninstalled via uninstall Make target…

cd ~/git/hub/awk-utilities/column-uniquely-sorted

make uninstall

Upgrade

To update in the future use make upgrade command…

cd ~/git/hub/awk-utilities/column-uniquely-sorted

make upgrade

Documentation

After installation documentation may be accessed via man command, eg…

man column-uniquely-sorted.awk

Example Usage

file-one.txt

foo
bar
spam
ham

file-two.txt

foo
lamb
spam
ham

By default the column-uniquely-sorted.awk script will sort unique lines, not just an individual column…

column-uniquely-sorted.awk file-one.txt file-two.txt
#> bar
#> foo
#> ham
#> lamb
#> spam

And it is possible to instead sort by count, as well as reverse sort order…

column-uniquely-sorted.awk --count\"
                           --reverse\" 
                           file-one.txt\
                           file-two.txt
#> 2 spam
#> 2 ham
#> 2 foo
#> 1 lamb
#> 1 bar