简体   繁体   English

Powershell参数错误'p'

[英]Powershell parameter error 'p'

I tried typing this command 我试着输入这个命令

mkdir -p lol\hit\xx

But I get an error message 但我收到一条错误消息

mkdir: Parameter cannot be processed because the parameter name 'p' is ambiguous.

I am following a tutorial online and according to that, there shouldn't be any error. 我在线跟踪教程,据此,不应该有任何错误。 What is the reason behind this? 这背后的原因是什么?

mkdir, when run in PowerShell, runs as an alias to New-Item. mkdir,在PowerShell中运行时,作为New-Item的别名运行。 This can be seen by running Get-Help mkdir within PowerShell. 通过在PowerShell中运行Get-Help mkdir可以看到这一点。

In that case -p is ambiguous because it could be either of the -Path or -PipelineVariable arguments for New-Item. 在这种情况下,-p是不明确的,因为它可能是New-Item的-Path-PipelineVariable参数。 I believe that what you want is: 我相信你想要的是:

mkdir -path lol\hit\xx

That will create the lol folder at your current location, and the hit folder inside it, and the xx folder inside of that. 这将在您当前位置创建lol文件夹,并在其中创建命中文件夹,以及其中的xx文件夹。

The -p switch for mkdir in Unix forces the command to create all folders needed to get to the path you designate (so if all you had was 'lol' it would creates the 'hit' folder within that, and then create the 'xx' folder within the 'hit' folder). Unix中mkdir的-p开关强制命令创建到达你指定路径所需的所有文件夹(所以如果你只有'lol'那么它会在其中创建'hit'文件夹,然后创建'xx ''hit'文件夹中的文件夹)。 PowerShell's New-Item does this by default. PowerShell的New-Item默认执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM