Command line – Copy the SSH public key to the clipboard WITHOUT new line added

Every search on Google to copy a SSH public key from a Mac to the clipboard gives the following command: which gives a new added line:

pbcopy <~ / .ssh / id_rsa.pub

This is not desirable because I have to paste a public key in a variable of an application that I develop. In the hope of avoiding people the trouble of solving the same problem, I will post my solution to this question.