How to Copy the Command Output to Windows Clipboard

Like it or not, the command prompt is still an indispensable part of your Windows computer because there are still a bunch of things that can only be done by writing commands.

For instance, if the computer isn’t connecting to the Internet, you will probably be interested in the output of the “ping” or the “tracert” command. If you need to print the contents of a directory in Windows, the command “dir” will come to your rescue.

Copy Output to Clipboard Copy command line output to Windows Clipboard

Now here’s a little trick. If you add the pipe* operator (|) to your command followed by the “clip” command, the output of your original command will get saved to the Windows clipboard and won’t print inside the Command Prompt window.

Here are some examples:

  • dir | clip Copy the content of a folder to the clipboard.
  • tree | clip  Display the recursive directory structure and save it to the clipboard.
  • type error.log | clip Place the content of the file error.log to the clipboard.
  • sort file.txt | clip Sort the file and save the sorted output to the clipbord.
  • ipconfig /all | clip Get details of your network connection for sending to tech support.

The “clip” command may not be available on Windows XP but in that case, you can use the redirect operators, like > and >>, for saving the command output to a text file.

Alternatively, right-click anywhere inside the command window, select Mark from the contextual menu, use the mouse to highlight a block text and then press Enter to save it to the clipboard.

[*] The pipe operator (|) takes the output of one command and directs it into the input of another command which in our case is clip.

Amit Agarwal is a web geek, solo entrepreneur and loves making things on the Internet. Google recently awarded him the Google Developer Expert and Google Cloud Champion title for his work on Google Workspace and Google Apps Script.

Awards & Recognition

Google Developer Expert

Google Developer Expert

Google awarded us the Developer Expert title recogizing our work in Workspace

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional title for 5 years in a row

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator award for technical expertise

Want to stay up to date?
Sign up for our email newsletter.

We will never send any spam emails. Promise 🫶🏻