Help With Running a Shell Command in KM

Thanks everyone for contributing. I ended up solving the problem using the custom action from Execute a Script in Terminal - #5 by Tom

Here is the working script if anyone else struggled: