Unix Text Editing Awesomeness

Oh, LaTeX acronym package, you won’t automatically alphabetize my list of acronyms? ┬áStrange… ┬áLet’s see if Unix will…

$ echo "\acro{SCADA}{Supervisory Control And Data Acquisition}
\acro{PLC}{Programmable Logic Controller}
\acro{RTU}{Remote Terminal Unit}
..." > toSort

$ for i in `cat toSort |sed "s/.*\\acro{\(.*\)}.*{.*}/\1/" | sort`;
do grep "{$i}" toSort; done
\acro{ADC}{analog to digital converter}
\acro{API}{application programming interface}
\acro{APT}{Advanced Persistent Threat}
\acro{ASCII}{American Standard Code for Information Interchange}

Unix, you rock my world.

2 thoughts on “Unix Text Editing Awesomeness

  1. Ha, nice! Is the sed part necessary? I see that you’re sorting by the acronym name, but since they all have the same prefix, wouldn’t a straight sort work too?

Leave a Reply

Your email address will not be published. Required fields are marked *