简体   繁体   中英

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. This can be seen by running Get-Help mkdir within PowerShell.

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

That will create the lol folder at your current location, and the hit folder inside it, and the xx folder inside of that.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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