CLIP - Copy to Clipboard

Maintained on

When you want to paste the result of a command into an email or a chat, selecting it on screen and copying it by hand is tedious.

The CLIP command copies whatever it receives on standard input to the clipboard. Combined with pipes and redirection, it lets you copy command output or file contents without touching the mouse.

Basic Usage

CLIP is not used on its own. You connect the output of another command to it with a pipe (|).

COMMAND | CLIP

Example

ipconfig | clip
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>ipconfig | clip

Nothing is displayed on screen, but the output of ipconfig is copied to the clipboard. Press Ctrl + V in Notepad or another app to paste it.

No message is shown on success

CLIP prints nothing when it succeeds. If you are unsure whether the copy worked, paste into Notepad to check.

The clipboard is overwritten

Running CLIP replaces whatever was on the clipboard before. It cannot be undone.

Copy the Contents of a File

You can feed the contents of a text file to CLIP with redirection (<).

clip < memo.txt

Combining the type command with a pipe gives the same result.

type memo.txt | clip

Either way, the whole file is copied without opening it.

Common Examples

Copy the current directory path

cd | clip

cd with no arguments prints the current folder path, and that is what gets copied.

Copy a list of file names

dir /b | clip

With /b, only the file names are copied, one per line.

Copy the location of an executable

where python | clip

Copy a short string

echo Hello| clip

Watch Out for the Trailing Newline

The output of echo ends with a newline, so echo Hello | clip (with a space before the |) copies “Hello”, that space, plus a line break. That is why the cursor moves to the next line after you paste.

That space becomes part of the string. If it matters, remove the space and write echo Hello| clip.

To copy a string without any newline, use set /p.

<nul set /p "=Hello" | clip

<nul supplies empty input, so only the text printed by set /p is passed to CLIP.

Clear the Clipboard

Passing nothing to CLIP empties the clipboard.

clip < nul

This is handy after pasting something like a password, so it does not stay on the clipboard.

When the Text Is Garbled

CLIP interprets text using the current code page of the Command Prompt. If a file saved as UTF-8 comes out garbled, change the code page first; this often fixes it.

chcp 65001
clip < memo.txt

The change lasts until you close that Command Prompt window. To restore it, run chcp 437 (or the code page you had before; the default on Japanese systems is 932). See the article on character encoding for details.

Example in a Batch File

Here is a script that puts a result on the clipboard so you can paste it later.

@echo off
ipconfig | findstr /C:"IPv4" | clip
echo The IPv4 address line has been copied to the clipboard.
pause
チェック

CLIP only copies; it cannot paste. To read the clipboard from the Command Prompt, use PowerShell’s Get-Clipboard, for example powershell -command "Get-Clipboard".

Summary

TaskCommand
Copy a command’s outputcommand | clip
Copy a file’s contentsclip < filename
Copy a string without newline<nul set /p "=text" | clip
Empty the clipboardclip < nul

Quiz

Practice Problem

Which command correctly copies the contents of memo.txt to the clipboard?

回答がサーバーに送信されることはありません
#Command Prompt #Batch File #CLIP #Command #Clipboard