## Problem statement

I’m writing a Jenkins job to produce a file with a list of canonical urls from two separate sources. One source looks like this

The second looks like this

What I want is

Basically, I want to join two files together by brand which I could have done that in SQL.

So my initial thought would be something like this

This is way too slow because I have about 900k of urls to filter and every url will do a O(n) search. Also, I created a lot of sub-shells

And I thought hmm if I can make that a constant operation using some kind of Map then it would be a lot faster. I immediately thought of Map or associative array but my shell doesn’t have associative just yet. People might wonder why can’t I just use python or node script to manipulate that. I could have but I just want a script to run in Jenkins and bash is available already. I don’t have to install any runtime.