使用Windows的Linux子系统(LSW),clip.exe
可用于将数据复制到Windows剪贴板:
$ 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.
有什么方法可以传送 FROM 剪贴板吗?预期用途示例:
$ paste.exe > foo.txt
$ paste.exe | tr , '\n' | clip.exe
答案 0 :(得分:1)
解决方案
这会将Windows的剪贴板打印到标准输出:
powershell.exe Get-Clipboard
示例
$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello
$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13
$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world
来源:https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532
别名
这是@Gordan Bean中有用的别名,它删除了\r\n
:
alias paste.exe="powershell.exe Get-Clipboard | perl -p -e 's/\r\n$//'"