10

I have a Unix script which uses the command

Current_Dir=`pwd`

What would be the suitable replacement for it in Windows Power shell script?

user2864740
  • 60,010
  • 15
  • 145
  • 220
user2879237
  • 103
  • 1
  • 1
  • 5

4 Answers4

16

Both of these are valid if you are trying to make a var with your current dir:

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

The development team for Powershell contains a couple of Unix guys, so there are some goodies in there like ls, pwd and cat

Vasili Syrakis
  • 9,321
  • 1
  • 39
  • 56
12

Use the $pwd.Path expression

write-host $pwd.Path
JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
7

Just use "pwd", or "Get-Location" ("pwd" is just an alias for "Get-Location").

ALso: you don't need the quotes in PS, like you do in a Unix shell.

FoggyDay
  • 11,962
  • 4
  • 34
  • 48
2

Powershell has many of the same commands as Linux. pwd is the command equivalent. When you type pwd in Powershell, it is an alias to Get-Location.

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

Community
  • 1
  • 1
enedil
  • 1,605
  • 4
  • 18
  • 34