开发者

How do I capture bash output to the Mac OS X clipboard?

Is it possible to capture ba开发者_如何学Gosh output to the OS X clipboard?


The pbcopy command does this.

For example, this puts the output from ls on the clipboard/pasteboard:

ls | pbcopy

And pbpaste does the reverse, writing to stdout from the clipboard:

pbpaste > ls.txt

You can use both together to filter content on the clipboard - here's a rot13:

pbpaste | tr 'a-zA-Z' 'n-za-mN-ZA-M' | pbcopy


In case you want to capture error messages, this will work:

cmd 2>&1  | pbcopy


You can do this using the pbcopy command:

pbcopy < ./path/to/file/or/output/stream
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜