如何捕获bash输出到Mac OS X剪贴板? [英] How do I capture bash output to the Mac OS X clipboard?

查看:92
本文介绍了如何捕获bash输出到Mac OS X剪贴板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将bash输出捕获到OS X剪贴板?

Is it possible to capture bash output to the OS X clipboard?

推荐答案

pbcopy 命令执行此操作。

例如,这会将 ls 的输出放在剪贴板/粘贴板上:

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

ls | pbcopy

pbpaste 进行相反的操作,从剪贴板写入stdout:

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

pbpaste > ls.txt

您可以将两者一起用于过滤剪贴板上的内容-这是 rot13

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

这篇关于如何捕获bash输出到Mac OS X剪贴板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆