作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
例如,我想在屏幕上显示输出并将其复制到剪贴板。
dir | tee con | clip
上面的代码不起作用,因为 con
在 PowerShell 的文件系统中未被识别为控制台。
还可能有如下场景,
Get-LongLongOutput |
tee con | # Monitor the intermediate output
Process-LongLongInput |
Process-LongLongInput2 |
.....
最佳答案
您将要收集您的管道数据并将其单独发送到剪贴板,正如@Mathias R. Jessen 所建议的那样。这样做的原因是 Clip
实际上是一个外部应用程序,而不是内置于 PowerShell 中的东西,它使用管道传输给它的信息,除了将信息复制到剪贴板上之外没有任何“输出”。
dir | tee -var data
$data | clip
这(如@Mathias R. Jessen 所建议)将显示您的内容,并将其复制到剪贴板。
或者,您可以在 ForEach 循环中使用 Write-Host
将内容写入屏幕,并且仍然能够将它们通过管道传递给 clip
,但它的格式可能不合需要,大多数人建议尽可能避免使用 write-host
。如果你想那样做,你可以使用类似的东西:
dir | ForEach-Object{
Write-Host $_
$_} | Clip
关于命令提示符 con 的 Powershell 通讯员?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31818045/
我想知道是否还有诸如标签之类的东西? 我已经在我的图像上使用了标签,但我必须使用多个标签来创建我的代码,我还没有找到一种方法...因此我想知道是否还有其他事情可以类似于标签?另一种“标记”图像的方法?
例如,我想在屏幕上显示输出并将其复制到剪贴板。 dir | tee con | clip 上面的代码不起作用,因为 con 在 PowerShell 的文件系统中未被识别为控制台。 还可能有如下场景,
我是一名优秀的程序员,十分优秀!