36
3
I'd like to do something like
dir *.* > clipboard
ie. get to get the standard output of a command line program copied to the clipboard. Can this be done on a standard XP machine without additional programs?
36
3
I'd like to do something like
dir *.* > clipboard
ie. get to get the standard output of a command line program copied to the clipboard. Can this be done on a standard XP machine without additional programs?
31
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.
2as a historical note, Arjan's link to the MS support note references NT4. but you're probably right that consumer versions of Windows didn't include clip.exe before Vista. – quack quixote – 2010-01-19T13:47:02.533
Oh, fair enough. Never really get a chance to mess around on business machines! :( – Phoshi – 2010-01-19T15:42:02.270
if it's any consolation, i completely missed out on all the fun of Windows NT 3.51. and i wasn't a fan of NT at all until i got to play with 2000 for a while. – quack quixote – 2010-01-19T15:45:14.477
18
For Windows and non-Windows, this post (dead link) used to say:
On Windows Vista or later, try:
echo hello | clip
On Linux, try:
echo hello | xclip
On Mac OS X, try:
echo hello | pbcopy
For example, you might do
(cat myFile.txt | xclip)
. This would basically allow you to edit the clipboard directly.
(I came here via Google looking for the Mac equivalent of xclip
)
Similarly for contents of files (as you don't cat
on windows):
type filename | clip % OR clip < filename %windows cat filename | xclip # OR xclip < filename # X11 / Unix / Linux cat filename | pbcopy # OR pbcopy < filename # MacOS X
1The link above is now throwing a 500. For those of you unfamiliar with pbcopy
, <kbd>Command</kbd>+<kbd>V</kbd> doesn't paste: you need to type (or alias to something shorter) pbpaste
. – eebbesen – 2015-01-14T14:48:00.727
6
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 instead.
comment #3 here:
http://ubuntuforums.org/showthread.php?t=413786
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).
Since you've mentioned perl, I would like to add that ruby and python provide similar library too. – weakish – 2012-09-30T11:33:42.400
4
There's no standard way, but you can apparently use clip.exe
which came with the Windows Server 2003 resource kit . Source
The problem now becomes getting hold of a legal copy of this.
I wonder how legal that is. What sort of licensing do MS put their small cli tools under, I wonder? – Phoshi – 2010-01-19T12:42:38.250
1It was also available in the NT 4 and Server 2000 Resource kit if you have either of those available to you. It does not seem to be available in the now free-to-download subset of the 2000 RK tools. – AdamV – 2010-01-19T15:27:29.260
2
Windows users can get gclip.exe
as part of a big bundle of tools, which allows you to do just this.
1
In PowerShell, it can be done like this:
dir *.* | clip
1clip is just an external tool so it'll work in any consoles, not only powershell – phuclv – 2016-01-08T08:03:08.617
1
As an aside: see "Clip.exe Not Compatible with Notepad" at http://support.microsoft.com/kb/172596
– Arjan – 2010-01-19T12:44:44.4872That link isn't relevant to PowerShell. I've tested it and everything works fine with Notepad. – Mark – 2010-01-19T12:48:49.173
I can confirm that this works on XP, IF a Server 2003 clip.exe is in you path. Also works in a standard CMD prompt – Shevek – 2010-01-19T12:54:13.577
0
As of Windows Vista and later DOS has a built in clip command:
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.
-1
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'
Welcome to Super User! Please read the question again carefully. Your answer does not answer the original question. clip
does not exist on Windows XP. – DavidPostill – 2016-09-09T20:38:00.157
http://superuser.com/questions/231023/windows-script-to-copy-some-text-to-the-clipboard/231032#231032 mentions http://www.petri.co.il/software/clip.zip which is apparently on windows server 2003 or the 2003 resource kit maybe. But there it is for download – barlop – 2013-09-10T14:55:14.497
7Just for the archives: the Mac OS X equivalents are called
pbcopy
andpbpaste
. – Arjan – 2010-01-19T12:45:28.620