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> | clipFor 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.txtIn 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.
No comments:
Post a Comment