当我在 VSCode 终端中运行 dir /p 时,我得到:
PS C:\Users\moren\source\repos\TrentonTompkins.com> dir /p
dir : Cannot find path 'C:\p' because it does not exist.
At line:1 char:1
+ dir /p
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\p:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
它适用于命令提示符。 dir /p 返回 1 页的项目,如果您有 1000 个项目并且确实想阅读它们,这很好。
dir /p 在 Windows 10 PowerShell 中不起作用。我猜测 VSCode 使用 PowerShell 而不是 cmd.exe。
有没有办法在 PowerShell 中执行 dir /p ?我尝试尝试 help dir,但它似乎没有选项只返回一组结果。
我应该将 VSCode 中的终端设置为 cmd.exe 吗?我可以考虑使用 PowerShell 的唯一原因是我可以 wget,但即使这也不是真正的 wget,因为您必须使用 -O 选项来实际保存文件。我想我可以将默认终端切换到 cmd.exe,安装适用于 Windows 的 wget 并将其全部安装到我的路径中,如果我需要 PowerShell,只需运行 PowerShell。
谢谢。我尝试了 cmd dir /p,我不知道我需要 /c 标志来为其提供命令。我在 VSCode 中将终端更改为 cmd,现在我可能会将其改回来,哈哈。
PowerShell 相当于
dir /p
是:
Get-ChildItem | Out-Host -Paging
或更短版本:
dir | oh -p
正如 Olaf 所指出的,PowerShell 中的
dir
是 Get-ChildItem
的别名:
Get-Alias dir
# CommandType Name Version Source
# ----------- ---- ------- ------
# Alias dir -> Get-ChildItem
如果您想运行原始的
dir
命令,您需要使用 cmd /c
:
cmd /c dir /p