首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >用于windows的linux子系统中的剪贴板管道。

用于windows的linux子系统中的剪贴板管道。
EN

Stack Overflow用户
提问于 2019-05-03 17:18:04
回答 1查看 2.5K关注 0票数 11

使用(LSW),可以使用clip.exe将数据复制到Windows剪贴板:

代码语言:javascript
运行
复制
$ clip.exe /?

CLIP

Description:
    Redirects output of command line tools to the Windows clipboard.
    This text output can then be pasted into other programs.

Parameter List:
    /?                  Displays this help message.

Examples:
    DIR | CLIP          Places a copy of the current directory
                        listing into the Windows clipboard.

    CLIP < README.TXT   Places a copy of the text from readme.txt
                        on to the Windows clipboard.

有什么方法可以从剪贴板的上输送吗?打算使用的例子:

代码语言:javascript
运行
复制
$ paste.exe > foo.txt

$ paste.exe | tr , '\n' | clip.exe
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-13 15:36:10

溶液

这会将Windows的剪贴板打印到stdout:

代码语言:javascript
运行
复制
powershell.exe Get-Clipboard

示例

代码语言:javascript
运行
复制
$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello
代码语言:javascript
运行
复制
$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13
代码语言:javascript
运行
复制
$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world
代码语言:javascript
运行
复制
paste() {  # Add me to your .bashrc, perhaps.
    powershell.exe Get-Clipboard | sed 's/\r//'
    # The `sed` will remove the unwelcome carriage-returns
}

来源:https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532

票数 20
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55974462

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档