Powershell 参数错误“p" [英] Powershell parameter error 'p'

查看:45
本文介绍了Powershell 参数错误“p"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着输入这个命令

mkdir -p lol\hit\xx

但我收到一条错误消息

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,在 PowerShell 中运行时,作为 New-Item 的别名运行.这可以通过在 PowerShell 中运行 Get-Help mkdir 来查看.

mkdir, when run in PowerShell, runs as an alias to New-Item. This can be seen by running Get-Help mkdir within PowerShell.

在那种情况下 -p 是不明确的,因为它可以是 New-Item 的 -Path-PipelineVariable 参数之一.我相信你想要的是:

In that case -p is ambiguous because it could be either of the -Path or -PipelineVariable arguments for New-Item. I believe that what you want is:

mkdir -path lol\hit\xx

这将在您当前的位置创建 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.

Unix 中 mkdir 的 -p 开关强制命令创建到达您指定路径所需的所有文件夹(因此,如果您拥有的只是lol",它将在其中创建hit"文件夹,然后创建'hit' 文件夹中的 'xx' 文件夹).默认情况下,PowerShell 的 New-Item 会执行此操作.

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). PowerShell's New-Item does this by default.

这篇关于Powershell 参数错误“p"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆