Copy command line output to the clipboard on Mac and Windows

October 12, 2018

In each example below, the contents of a file are copied to the clipboard.

Mac

cat <file> | pbcopy

Windows

type <file> | clip