How-To Geek

How to Copy Output Text from the Command Line to the Windows Clipboard

If you’re doing work at the command line on your Windows box, it’s sometimes useful to copy the output of a command to the clipboard, but who wants to try and scroll and click to use copy and paste? Here’s how to do it the easy way.

Note: For the purposes of our exercise, we’ll be using the built-in clip utility in Windows 7 or Vista—if you are using Windows XP, you can download clip.exe from Microsoft, just make sure to save the file in the Windows directory.

Copy Output from Command Line Applications to the Clipboard

To copy text from a command to the clipboard, we’ll just pipe it into the clip command, like this:

<command> | clip

For example, if you wanted to output from the echo command into the clipboard, you could do this:


You can also use redirection to send a text file directly into the clip utility, like this:

clip < filename.txt

In this example I’m gonna put the contents of the single.php file onto the clipboard:


Of course, you could also use the type command and then pipe it to the clipboard like so:


Regardless of the one you use, you’ll then be able to paste the content into any other application that you’d like:


Create a Context Menu Helper to Copy File Contents to the Clipboard


You can take the clip utility a step further by adding a context menu item that lets you copy the contents of any file directly to the clipboard. All you’ll need to do is follow the instructions in the following article, or download the reghack file.

Create a Context Menu Item to Copy a Text File To the Clipboard in Windows 7 / Vista / XP

And of course, don’t forget that you can always copy the path of the file to the clipboard through the context menu.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 09/10/10

Comments (2)

  1. InDiSent

    I notice that piping the output to clip does not display it in the cmd prompt window. Is there a way to get it to display the output and send it to the clip board?

  2. Camilo Martin

    @InDiSent yeah tee.exe

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!