How can I copy and paste the complete contents of a PEM file? I found out that I can view the contents of a PEM file by pressing the Spacebar, it's not possible to select the text.

How can I copy and paste the file contents, because I need to paste it in this text field:


https://api.playfab.com/docs/tutorials/landing-players/push-notification-basics/push-notifications-for-ios


The contents of my PEM file look weird after opening it in the terminal. Is this normal? Because when I open the file with Spacebar the contents look completely different and much more normal than these lines.

In Terminal:

-----BEGIN CERTIFICATE-----
MIIFtzCCBJ+gAwIBAgIIRA1/KqHYmg8wDQYJKoZIhvcNAQEFBQAwgZYxCzAJBgNV
BAYTAlVTMRMwEQYDVQQKDApBcHBsZSBJbmMuMSwwKgYDVQQLDCNBcHBsZSBXb3Js
ZHdpZGUgRGV2ZWxvcGVyIFJlbGF0aW9uczFEMEIGA1UEAww7QXBwbGUgV29ybGR3
aWRlIERldmVsb3BlciBSZWxhdGlvbnMgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkw
HhcNMTkwNjE4MTQzNTE1WhcNMjAwNjE3MTQzNTE1WjCBtjE5MDcGCgmSJomT8ixk
...
-----END CERTIFICATE-----
I found out that I can view the contents of a PEM file by pressing the Spacebar, it's not possible to select the text.


This feature is called Quick Look in macOS. Quick Look is a handy tool to quickly view a file's content without launching any app.

To quickly copy the contents of the PEM file to clipboard, launch Terminal.app, change to the directory containing the PEM file and run the following command (Here assume the name of the PEM file is pemfile.pem and it is located in ~/Downloads directory):

pbcopy &lt; ~/Downloads/pemfile.pem 


The command won't output anything in Terminal. The PEM file contents are now copied into clipboard.

Now you can go to the desired text field and paste the copied contents by using the macOS paste keyboard shortcut Command + V.




  The contents of my PEM file look weird after opening it in the terminal. Is this normal? Because when I open the file with Spacebar the contents look completely different and much more normal than these lines.


The contents are completely normal. That's how the contents of a PEM file looks. The actual textual contents of the PEM file are not shown when using Quick Look. To view full contents of the PEM file, open it using a text editor.