How to copy input from from the clipboard using pbcopy and setting that to another file that can then be called by pbpaste

506 Views Asked by At

I want to get the data from the main clipboard onto my own file so that when the user executes a command they can retrieve the information set upon that second file. Alternatively I could also pbcopy direcly into the second file and run that command with pbpaste. Could someone smarter than me tell me how to do this. I have searched for hours now.

1

There are 1 best solutions below

0
Wim Lewis On

pbpaste reads from the clipboard/pasteboard and writes to stdout (as if you are pasting), so you can copy your pasteboard to a file using pbpaste > filename. You can then do whatever you want with the file. pbcopy puts something onto the pasteboard, so if you want to put a file's contents into the pasteboard you can do that with pbcopy < filename.

The < and > operators are shell redirection operators, which you can learn more about in a command-line or unix tutorial.