TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Linux Bash vs. Windows PowerShell

35 pointsby vedipenabout 5 years ago

19 comments

AdmiralAsshatabout 5 years ago
Article might be more successful if it demonstrated some of the advantages of PowerShell, such as returning the output as objects instead of lines, and what you can do with them as a result.<p>I&#x27;ll admit to being in the &quot;Bash is what I know, I&#x27;ll just install WSL&#x2F;Cygwin&#x2F;PuTTY on my Windows workstation and be done with it&quot; crowd. PowerShell is on my bucket list of things I need to learn at some point, or at the very least just get a RosettaCode cheatsheet of common stuff I do in bash and how to do it in PowerShell for when I&#x27;m stuck on remote Windows servers.
评论 #22849294 未加载
评论 #22848631 未加载
评论 #22849569 未加载
评论 #22848730 未加载
JamesSwiftabout 5 years ago
I dev on a Mac and do a lot of &#x27;quality of life&#x27; scripting with Bash. I recently had to do something on a PC and figured I&#x27;d try out Powershell. I have to say, it was a joy. Dealing with objects instead of text is so refreshing, it really is a game changer especially when you start integrating with COM (e.g. excel).<p>The only things I found worse:<p>1 - error handling doesnt bubble in the same way. e.g. I can&#x27;t do an equivalent of `set -e`, or do `cmd &amp;&amp; other_cmd`<p>2 - return values are very nuanced. If you don&#x27;t understand how function statement contribute to the result, you will spend a lot of time debugging odd issues
评论 #22850952 未加载
评论 #22848925 未加载
评论 #22848913 未加载
评论 #22848836 未加载
oefrhaabout 5 years ago
I think PowerShell doesn’t really compete with Bash, it competes with Python, Perl or the like. And I haven’t found it to be superior in that aspect other than at integration with Windows system stuff.
评论 #22848711 未加载
评论 #22848882 未加载
skywhopperabout 5 years ago
This is a pretty poor comparison of the two, especially once it gets into the syntax, of which most of the Bash examples are broken in some way.<p>There’s also a lot of just straight errors, such as mentioning “true” and “false” “values” in Bash, which don’t exist—the userland toolset includes “true” and “false” programs that can be used to inject desired exit code status into some logic flow, but there is no real concept of a Boolean type.<p>Overall, if you’re going to provide a rundown of how x and y compare, you should probably give real examples, not just a laundry list of “instead of grep, we use select-string; instead of sed we use -replace”. But <i>how</i> do you use them? I worked with Powershell some over a decade ago, but this article doesn’t give enough info for me to understand what to do with the information it’s providing. And given the errors in describing how Bash works, I’m skeptical that the Powershell examples are syntactically correct either.
评论 #22848565 未加载
评论 #22848914 未加载
BiteCode_devabout 5 years ago
If you need crossplatform scripting and will install a runtime, why go powershell or bash ? Something like ruby or python seems more adpated.
评论 #22848890 未加载
评论 #22848678 未加载
vardumpabout 5 years ago
The biggest issue in PowerShell is very slow script execution startup time, 300-500ms seems to be typical. So forget about externally launching PowerShell scripts thousands of times.<p>The second biggest issue I&#x27;ve seen is generic lack of robustness and maturity. Default cmdlets do the common case nicely, but once you have something unusual in the mix things go wrong fast... By unusual, I mean things like filesystem junctions, volumes mounted into directories.<p>If you want colors, Write-Host is nice. Except that it goes only to console AND to (undocumented?) file id 6! (same way like stdout goes to 1, stderr to 2, etc.).<p>PowerShell seems to behave slightly differently in each Windows version. A script that&#x27;s written for Win10 1803 might just break under 1809.<p>I don&#x27;t have much issues with Bash etc., even sh. It performs well and is very robust. I do hate its many footguns, like how easy it is to get escaping wrong.
评论 #22849253 未加载
remveeabout 5 years ago
@vedipen, thera&#x27;s a typo in bash &quot;if&quot; example, an if-block is closed with &quot;fi&quot;.<p>edit: &quot;if&quot; example also misses a semicolon before &quot;then&quot;.
评论 #22848636 未加载
colonwqbangabout 5 years ago
There are so many errors in his bash code, it makes you doubt the author&#x27;s basic bash competence. None of his examples use fully correct bash syntax.
vehemenzabout 5 years ago
Just going to leave this here:<p>Known Issues for PowerShell on Non-Windows Platforms<p><a href="https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;powershell&#x2F;scripting&#x2F;whats-new&#x2F;known-issues-ps6?view=powershell-7" rel="nofollow">https:&#x2F;&#x2F;docs.microsoft.com&#x2F;en-us&#x2F;powershell&#x2F;scripting&#x2F;whats-...</a>
mpawelskiabout 5 years ago
I use PowerShell for quite some time (mostly windows&#x2F;.NET guy here) and it would be great tool except one thing: the amount of not obvious quirks is astounding and not really decreased over the years. Probably because of avoidance of breaking changes, which is understandable where there are tons on powershell scripts out there. But for for someone who uses it mostly as a shell to write one liners or occasionally write a script not longer than 30 lines of code, it&#x27;s really discouraging when you encounter again some unexpected behavior (even though you thought you learned powershell &quot;good enoguht&quot; couple years ago).
评论 #22850985 未加载
elagostabout 5 years ago
Having used both, in a personal and professional capacity, I don&#x27;t think they occupy the same &quot;real estate&quot;. If you have a bunch of Windows systems to admin, sure, PowerShell works great with all the Windows built-ins. In fact, it works with SCCM pretty well. If your systems are Linux-based, you can use shell scripts to interface with something like Chef or Rundeck. Use something that works natively and is designed for the platform you need to orchestrate.
ape4about 5 years ago
I hate how long the PowerShell comand names are. Yes they are sensible but arg. Eg grep vs Select-String as the article mentions.
评论 #22848939 未加载
评论 #22848906 未加载
uk_programmerabout 5 years ago
The article does need a lot more fleshing out. As many have said here the thing that powershell has over bash is piping objects.
评论 #22849429 未加载
chowardabout 5 years ago
&gt; &quot;sample1&quot; -eq &quot;sample2&quot; -&gt; True<p>Why isn&#x27;t this false? Is it doing type checking instead of a value comparison?
评论 #22848532 未加载
goatinaboatabout 5 years ago
The real difference is: in any reasonable bash script there will be a significant amount of awk, cut, tr and other commands to munge the output of one command into the input expected by the next. In PowerShell that totally goes away.
评论 #22848578 未加载
评论 #22848922 未加载
评论 #22848786 未加载
评论 #22848537 未加载
评论 #22848642 未加载
metreoabout 5 years ago
How is the user experience different in Win where you actually need to use PS compared to the users need for Bash on Linux?
riobardabout 5 years ago
Not sure what the website did, but the page does not even scroll on iPad Safari.
评论 #22849289 未加载
评论 #22848685 未加载
altmindabout 5 years ago
Have anyone replaced *sh with powershell on linux for scripting?
weibingabout 5 years ago
a useless article