MacOS – move pdf through clipboard

copy/pastemacosmojave

$ cat scaswd.pdf| pbcopy
$ pbpaste > astasd.pdf
$ open astasd.pdf

astasd.pdf cannot be opened, but scaswd.pdf is a valid pdf file.

Is there a way I can stick a pdf onto my clipboard and paste it somewhere else?


I want to copy a file from my local computer to a remote one I can only access with ssh, without using intermediary file-hosting servers.

(I can't scp)

For text files copy and pasting between terminals works.

For binary files, like a pdf, I need another solution.

Best Answer

From the man page of pbcopy

pbcopy takes the standard input and places it in the specified pasteboard. If no pasteboard is specified, the general pasteboard will be used by default. The input is placed in the pasteboard as plain text data unless it begins with the Encapsulated PostScript (EPS) file header or the Rich Text Format (RTF) file header, in which case it is placed in the pasteboard as one of those data types.

So from this it would seem that only documents with RTF format or EPS format can be copied and pasted from these commands.

Finder does support copy and pasting files however, so cmd c, and cmd v, will copy and paste files in finder.