Skip to main content

TIL: comm

Sometimes you can find yourself in a situation where you need to compare two sets of data in your shell script. Until now I was unaware that rms is a co-author of the program does just that. The utility is called comm and you can probably find it in your distro’s core packages.

At work I have to track and request matlab licenses for my coworkers in the meta-team of over 100 people that changes quite dynamically lately. However, since it’s a big corpo, there are already some LDAP groups implemented at the company. All I had to automate was to fetch and compare the changes in the top-level group that contained all the teams.

comm made this super easy once I had the previous and current lists. Using the -13 and -23 options I could generate lists of people to add and remove. The data, however, had to be mailed to managers to get all the necessary approvals and blessings… But that was a trivial task since the mail body could be composed using a HEREDOC and piped directly to mail because the server where the cronjob was installed had a proper mail configuration.