Bash vs PowerShell

Bash vs PowerShell

  • Comments 42

Marcus Nasarek did a nice comparison of Bash vs PowerShell in Linux magazine HERE.  It is only 2 pages but he covers the key elements and has been very fair to it.  I appreciate the fact that he took the time to clearly understand PowerShell.  In the past, a number of people in the Linux community have assumed they knew what we were doing and did comparisons based upon their assumptions.  Those weren't very interesting.  

Enjoy! 

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Leave a Comment
  • Please add 8 and 6 and type the answer here:
  • Post
  • @Adam

    That all sounds nice and evil and all that let me point out a few things:

    1) Profits are a measure of value.  If you aren't delivering any value, you don't have any profits.  As such, being profit-oriented is a very good proxy for answering the question, "Are we doing what customers want?"

    2) MSFT has invested multiple 10's of millions of dollars in PowerShell and is making it free to all owners of Windows.  We've spent considerable time and effort to make it available all they way back to Windows XP (Any profit we got from that sale was a LONG time ago).

    3) As a team, we are incredibly passionate about solving the problems faced by our customers.  My original approach was to port BASH and UNIX utilities to Windows (You can look this up - I've been very open about this for many years).  The problem is that the UNIX approach is tuned around everything existing in ASCII text files and didn't work on Windows where we have stuff in the registry, AD, WMI, the cert store, etc.  Something new was needed.  We are NOT pushing a technology agenda - we are trying to solve the problems our customers face.  (Actually that isn't entirely true - I am pushing a technology agenda to move a bunch of the glop in those stores into Text files - but that is a different discussion).

    You should read Bruce Payette's book PowerShell In Action.  He does a good job explaining our "invent as little as possible" approach and the heavy influence that UNIX had on our thinking.

    Cheers.

    Jeffrey Snover [MSFT]

    Distinguished Engineer

    Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell

    Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

  • I think the article does not cover the details, but the conclusion seems to be correct powershell is object based script while in unix shell they have various very powerfull and  efficient utitilies which they combine with python for large projects. Powershell is very powerfull ( features of greak utilities like awk and grep can be achived through it) while working on object instead of text, but the one difference that I observed  is the speed , powershell is too slow, even a simple ls/dir will show the speed difference. But purpose of script is for administration and normally not used in time critical task so this does not make significant difference.  

  • I think the article does not cover the details, but the conclusion seems to be correct powershell is object based script while in unix shell they have various very powerfull and  efficient utitilies which they combine with python for large projects. Powershell is very powerfull ( features of greak utilities like awk and grep can be achived through it) while working on object instead of text, but the one difference that I observed  is the speed , powershell is too slow, even a simple ls/dir will show the speed difference. But purpose of script is for administration and normally not used in time critical task so this does not make significant difference.  

  • @Jeffrey Snover

    PowerShell looks interesting

    I'm still using bash, but thanks for contributing to technology

    I appreciate that you and you team have done this

    I would like to remind those that think PowerShell is unfit that the alternates are cmd.exe, COMMAND.COM, and bash.exe (from Cygwin)

  • @anonymous

    Thanks

  • First off, Microsoft has finally produced a meaningful command line. This is a Good Thing, whether or not it is a rip off of Bash or Unix. Fact of the matter is that the whole idea behind GNU and Open Source is that people can use the ideas and expand upon it. Microsoft is doing nothing wrong by expounding upon ideas already proposed openly for use and copy.

    I am always happy when Microsoft does the Right Thing, or anybody else for that matter. It doesn't make me a fan of Microsoft, but I won't detract away from good things on the same note.

    Now, Cygwin has been doing an equivalent job, if not better, for a long time. It's still my preference, but that is largely because I work on web servers where it is useful to be able to have a command line locally that runs in a similar manner as the servers I work on. That is why Cygwin is the Right Thing for me.

    For an IIS administrator, a power-user on Windows, and many other things, Powershell is going to be the Right Thing.

    Nobody is 'better' in every aspect for every application in any sense here. That has always been the case, and don't let dumb Windows users or smart Unix freaks tell you otherwise.

  • i 'm rading a book of powershell in action and i have stupefaction you have very impressionaite with in just 50 line creating a calculating

  • Languages (shells included) can be classified by how beautify the resultant script/code looks. Korn/Bourne are beautiful, PowerShell is extremely ugly.

    For those that don't believe PowerShell borrows heavily from ideas of Unix, then why does the "help" output look exactly like "man" output?

    I understand how everything is an object in PowerShell, but really, what's the point? It makes it harder to work with, not easier.

  • Languages (shells included) can be classified by how beautify the resultant script/code looks. Korn/Bourne are beautiful, PowerShell is extremely ugly.

    For those that don't believe PowerShell borrows heavily from ideas of Unix, then why does the "help" output look exactly like "man" output?

    I understand how everything is an object in PowerShell, but really, what's the point? It makes it harder to work with, not easier.

  • The linked linux-magazine article is a tragedy. The for-loop example in bash is complete non-sense:

    $ for ((i=1;i<=3;i++)); do echo $i; done

    1

    2

    3

    While it does technically work, no one who has a clue would ever do this in bash. First of all, variable references are always, always, always in double-quotes like so "$i"

    But beyond that, that syntax is obviously borrowed from C-like languages to help out newbies. The real bash syntax for a for-loop is:

    $ for i in {1..5}; do echo "$i"; done

    1

    2

    3

    4

    5

    So what's the BIG deal? how about the same syntax taking off the chains of integers?

    $ for i in {a..e}; do echo "$i"; done

    a

    b

    c

    d

    e

    Now what's the powershell equivalent? What if you need permutations of letter-number combos in bash?

    $ for i in {a..c}{1..3}; do echo "$i"; done

    a1

    a2

    a3

    b1

    b2

    b3

    c1

    c2

    c3

    *Now* what's the powershell equivalent? What if you need some user-friendly numeric labels?

    $ for i in 1st 2nd 3rd {4..9}th; do echo "$i"; done

    1st

    2nd

    3rd

    4th

    5th

    6th

    7th

    8th

    9th

    *NOW* what's powershell got?

    Long story short, it is commendable that M$FT is finally getting its admins a standard workable script solution, but it's no where close to being a real command shell. It's an object oriented scripting language for sure, but not a shell. That's my obvious takeaway from googling powershell this afternoon.

  • In reference to the comment about Automator...it seems really cool but do people actually use it that much?

  • The article correlates PS's "Get-Content" with the Unix tool "less". That's not correct. It's an equivalent of "cat", not "less".

Page 3 of 3 (42 items) 123