Current location

Windows 10 gives you the option of installing BASH on Ubuntu – https://msdn.microsoft.com/en-us/commandline/wsl/about also known as the Windows Subsystem for Linux (WSL). More information from https://blogs.msdn.microsoft.com/wsl/

I thought it would be interesting to compare some of the bash commands with their PowerShell equivalents.

First off – current location.

Its not obvious from the bash prompt where you are in the file system so you use pwd

root@RSsurfacePro2:~# pwd
/root

In PowerShell you use Get-Location

PS> Get-Location

Path
—-
C:\test

Interestingly you can use pwd in PowerShell

PS> pwd

Path
—-
C:\test

That’s because pwd is an alias for Get-Location

PS> get-alias pwd | fl

DisplayName       : pwd -> Get-Location
CommandType       : Alias
Definition        : Get-Location
ReferencedCommand : Get-Location
ResolvedCommand   : Get-Location

If you want to discover all existing aliases for Get-Location

PS> get-alias | where ResolvedCommand -like ‘get-location’ | fl

DisplayName       : gl -> Get-Location
CommandType       : Alias
Definition        : Get-Location
ReferencedCommand : Get-Location
ResolvedCommand   : Get-Location

DisplayName       : pwd -> Get-Location
CommandType       : Alias
Definition        : Get-Location
ReferencedCommand : Get-Location
ResolvedCommand   : Get-Location

You’ll find that many core PowerShell cmdlets have aliases corresponding to Linux commands. Note that they are removed for PowerShell on Linux to avoid confusion.

Look out for other comparisons soon.

Advertisements
This entry was posted in Bash, Powershell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s