ben lowery

Copy to clipboard from command line

Nov 25 2008

I just discovered a couple useful command-line tools on OSX and thought I’d share. pbcopy will copy stdin to the clipboard and pbpaste will send the clipboard to stdout.

$ cat somefile.txt | pbcopy #copy a file to the clipboard
$ pbpaste | grep foo #search the clipboard for foo

Handy.

Related posts:

  1. Commands
  2. Using post-build events to make your own app.config
  3. Playing with A9
  4. Finding those damn trailing commas
  5. Architecting the future

3 Responses to “Copy to clipboard from command line”

  1. pc accessories says:

    Nice article, i love it, thanks for sharing

  2. Marcelo Cantos says:

    grep foo < pbpaste doesn't do what you think it does.

  3. Ben says:

    Thanks Marcelo, I fixed the example.

Leave a Reply