我有一个使用命令
的Unix脚本Current_Dir=`pwd`
Windows Power shell脚本中适合替换它的是什么?
答案 0 :(得分:7)
使用$pwd.Path
表达式
write-host $pwd.Path
答案 1 :(得分:6)
如果您尝试使用当前目录创建var,则这两个都有效:
$current_directory = (pwd).path
$current_directory = pwd
Powershell的开发团队包含几个Unix人员,所以有一些好东西,如ls
,pwd
和cat
答案 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