Transfer-command-prompt-results

When most people run commands from the command prompt they either specify a text file to send the results to or more commonly just view the results in the prompt itself.

There’s a lesser known option we can use that sends the results not to the prompt or to a text file but straight to the clipboard (using “| clip”). This is great for commands that we normally will always copy, right after viewing or will need to copy from a text file after exporting anyway.

Different Ways to Show Results

We’re going to look at three ways we can show results from an executed command to get a feel for how this works. The first is with the regular command prompt as you’d see any result after running it. The next is using the aforementioned “| clip” addition, while the last is outputting the result to a text file.

Show in the Prompt

Let’s look at a regular ping operation. When we ping TechNorms.com without any fancy writing after the URL, we get the expected results of the different lines beneath the command and in the prompt window.

Ping-a-website-to-show-the-results-in-the-command-prompt-window

Copy to Text File

The same result occurs when we ping the same destination but use “ping TechNorms.com > result.txt” instead. This is specifying a text file as the output and not the command prompt.

image77

Copy to Clipboard

When we add “| clip” after the commands what we’re essentially doing is explicitly stating how to show the results. Or not show them, in this case. This “|” key is share with the backspace and is not normally used. Because we’ve specified to use the clipboard as the destination instead of the command prompt or file, we can then view the contents from a paste in a text editor.

A quick tip: The command ”clip < result.txt” can be used to grab the contents of the exported text file and insert it into the clipboard, in the event you’ve already made the file but don’t want to open it to copy the information.

Note this doesn’t work for every command because some commands don’t show results. For example, when you delete from the command prompt it doesn’t show any result in the form of text. Running “del result.txt | clip” will surely remove the text file but it will clear the clipboard and add nothing to it. A way to remember this is simply that if anything has a text output in the prompt, it can be redirected to the clipboard with this command in the same way it can be sent to a text file.

Conclusion

Exporting resulting text to the clipboard makes sending things like ipconfig results to your IT department or online helpdesk much easier than attempting to copy from the result in the command prompt. Bypass the use of a text file that needs to be opened before copying by simply sending it all straight to the clipboard.