在Windows PowerShell中替换`pwd`

use*_*237 4 powershell pwd

我有一个使用该命令的Unix脚本

Current_Dir=`pwd`
Run Code Online (Sandbox Code Playgroud)

Windows Power shell脚本中适合替换它的是什么?

Jar*_*Par 7

使用$pwd.Path表达式

write-host $pwd.Path
Run Code Online (Sandbox Code Playgroud)


Vas*_*kis 7

如果您尝试使用当前目录创建var,则这两个都有效:

$current_directory = (pwd).path
$current_directory = pwd
Run Code Online (Sandbox Code Playgroud)

Powershell的开发团队包含几个Unix人员,因此有一些好东西在那里ls,pwdcat


Fog*_*Day 6

只需使用“pwd”或“Get-Location”(“pwd”只是“Get-Location”的别名)。

另外:您不需要 PS 中的引号,就像在 Unix shell 中那样。