Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
317 views
in Technique[技术] by (71.8m points)

command line - Copy to clipboard using Bash for Windows

How do I copy results from the commandline directly to the clipboard?

On Windows's cmd.exe I can do simply echo "asd" | clip and it pipes output to the clipboard.

I tried to install xclip for that, and though it compiled, when called it prints:

Error: Can't open display: (null)

Using mouse is not the solution.

question from:https://stackoverflow.com/questions/43144008/copy-to-clipboard-using-bash-for-windows

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In Build 14393 or later, if you want to copy something to clipboard in WSL console, just add '.exe' to what you do in Windows cmd.

echo "aaa"|clip.exe

To read from clipboard:

powershell.exe -command "Get-Clipboard"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...