我知道这有点愚蠢,但我已经设置了一个自定义配置文件,以 Clear-Host
commandlet 结尾,我讨厌以前的 commandlet 的输出在屏幕。我决定将输出发送到 null 以试图抑制输出,例如:
New-Alias -Name note -Value notpad.exe > $null
它似乎在工作,但我不完全确定命令在做什么。这样做可以吗?
最佳答案
>
is a redirection operator .这在计算世界中很常见,在 unix (>/dev/null
) 和 Windows (> NUL
) 中。它通常用于写入文件或设备。在这种情况下,您将无处发送。
在 PowerShell 中执行此操作的其他方法:
Get-Something | Out-Null
[void](Get-Something)
$null = Get-Something
关于powershell -> $null 到底做了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37056618/