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

Amit Agarwal

Google Developer Expert, Google Cloud Champion

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.

Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory

0

Awards & Titles

Digital Inspiration has won several awards since it's launch in 2004.

Google Developer Expert

Google Developer Expert

Google awarded us the Google Developer Expert award recogizing our work in Google Workspace.

ProductHunt Golden Kitty

ProductHunt Golden Kitty

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

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional (MVP) title for 5 years in a row.

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator title recognizing our technical skill and expertise.

Email Newsletter

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

We will never send any spam emails. Promise.