在Windows PowerShell中替换`pwd`

时间:2014-02-18 06:42:50

标签: powershell pwd

我有一个使用命令

的Unix脚本
Current_Dir=`pwd`

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

4 个答案:

答案 0 :(得分:7)

使用$pwd.Path表达式

write-host $pwd.Path

答案 1 :(得分:6)

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

$current_directory = (pwd).path
$current_directory = pwd

Powershell的开发团队包含几个Unix人员,所以有一些好东西,如lspwdcat

答案 2 :(得分:4)

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

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

答案 3 :(得分:2)

  

Powershell有许多与Linux相同的命令。 pwd是命令等价物。   在Powershell中键入pwd时,它是Get-Location的别名。

https://superuser.com/questions/295021/windows-powershell-equivalent-to-unix-linux-pwd