用 clip.exe 把命令输出复制到剪贴板
Windows 自带 clip.exe——把任意命令的输出管道给它,结果就进了剪贴板,直接可粘贴到邮件或工单里。
运行 `<命令> | clip` 复制输出,或用 `clip < 文件.txt` 复制文件内容。
01命令
命令
$ type error.log | clip02作用说明
clip 读取标准输入直到 EOF,所以能和任何命令组合:`ipconfig /all | clip`、`Get-Content log.txt | clip`,连 `dir | clip` 都行。注意 PowerShell 管道传的是对象——在意格式时用 Out-String 或走 cmd 风格的重定向。反方向的对应工具是 PowerShell 的 Get-Clipboard,两者配合无需安装任何工具即可实现简单的复制粘贴自动化。
03风险
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- clip | Microsoft Learn依据: Microsoft documents clip.exe as reading standard input and placing it on the clipboard, with example redirects and pipes.
- CLIP - Windows CMD依据: SS64 shows clip usage with redirection (< file) and pipes (| clip) to copy text or command output to the clipboard.
最后验证: 2026-09-17 · 分类: 开发者