Home » Questions » Computers [ Ask a new question ]

How to pipe text from command line to the clipboard

How to pipe text from command line to the clipboard

I'd like to do something like

Asked by: Guest | Views: 126
Total answers/comments: 5
Guest [Entry]

I don't believe so - Vista (or NT4) introduced the clip tool, which would do your command as dir | clip - but there's nothing on XP. If you're willing to use 3rd party applications, though, there's this, which works as above, except is called cb, not clip.
Guest [Entry]

"I looked into this for myself earlier today. Below is something helpful to those wanting to insert and retrieve information from the clipboard in a linux distribution. Below that is something that could prove helpful for those with windows.


By default, xclip uses the ""primary"" clipboard, which is what you have copied with your mouse. To get it to use the manual copy clipboard, use xclip -sel clip

comment #3 here:


The functionality is available in Active Perl distribution also, which is what I wound up using on the windows box in this exercise; The windows clip.exe didn't appear to allow for reading the data from the clipboard (only writing into clipboard).

Guest [Entry]

"In PowerShell, it can be done like this:

dir *.* | clip"
"In PowerShell, it can be done like this:

dir *.* | clip"
Guest [Entry]

"As of Windows Vista and later DOS has a built in clip command:


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.

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."
Guest [Entry]

"If you're using cygwin on Windows (e.g. git for windows).
You better dump the content into a temp file,
then 'unix2dos' the temp file before really pipe to 'clip'"