the arduino IDE (integrated development environment program) will create (compile) the code to create the hex file (firmware) and then copy it (upload) to the Arduino mega flash storage memory. The program used to upload it is avrdude and it just reads the hex file and sends it to the arduino Mega. If you find where AVRdude is on your hard drive, you can call it directly and not have to compile the program first if you already have the hex file. If you used windows, there is a program called AVRdude GUI and it will allow you to push buttons to make it work. The text commands from the terminal on your mac will need to be used to get that to work. it is a bit tricky though, so it may take a few failures to get it right. If it isn’t right, it just won’t work. Hang in there. Keep trying.