It’s fine to prefer one tool over the other but bashing the one you’re less familiar with is unnecessary :)
It’s fine to prefer one tool over the other but bashing the one you’re less familiar with is unnecessary :)
Face it folks, it’s not bash’s fault if you use it seldom enough that you need a reminder of the syntax when you do. Nothing wrong with that!
I think your comment convinced me to never use bash again. Now onto finding a replacement... If people say they use bash because it is preinstalled they can go screw themselves. Install whatever replacement I'm going to pick and shut up.
To me the issue is why learn a different language for scripting? Python is the obvious replacement, but even Java write scripts in, I'm pretty sure any major language can compile and run easily.
Of course python comes with its own package management and system version clashes
Shells are pretty decent at piping and spawning subprocesses. They suck at anything algorithmic, numeric, etc. Thankfully those tasks can usually be handed off to a separate tool (e.g. classic Unix text processing tools, like sed/grep/cut/etc., or more recent data processing tools like jq, mlr, etc.)
Except with Bash it really isn't worth it. Learning PowerShell is much better for long scripts.
Just wait a couple decades and languages slowly improve or they die. Sometimes it takes a long time (in comparison to a person's lifespan) and that's ok.
This form `Verb-LongNoun` for function names used in PS is somewhere between alien and maddening. It's difficult to type, difficult to remember, and isn't an obvious improvement over `lowercasename` which is typical of basically every other shell.
I guess the idea is that you don't have to worry about naming collisions with programs in your path? That's never been an issue for me when writing shell scripts though, not even once.
I’m not OP but things I like about PowerShell:
- Objects instead of text
- The entire C# std lib is accessible
- One tool with the same UX vs several different tools with different UX.
But the single best feature of PS is that you pipe structured objects to the next command, instead of raw text that must be parsed, which is prone error. Every command output object can be exported to JSON with ConverTo-JSON. You can export the entire Active Directory as JSON with
Get-ADObject -Filter * | ConvertTo-JSON > AD.json
Some more examples.
Get-ChildItem -Path *.txt | Where-Object {$_.length -gt 10000} | Sort-Object -Property length | Format-Table -Property name, length
Get-Item -Path HKLM:\Software\MyCompany | New-ItemProperty -Name NoOfEmployees -Value 8124
Get-Process | Sort-Object -Property handles
I agree with that, but other advanced shells (xonsh, elvish, or even fish) also have this feature.
Bash has been around for 33 years. Much of its syntax has been around for 52 years through sh.
Ofc this is bigger thinking than the Powershell vs Bash debate, per se. Powershell is more useable as a language, if not by pure syntactic maturity, than by features alone. There will always be someone who will disagree with the obvious, but there's no doubt that the algol syntax is going away...however long that will take.
I’m not buying what you’re selling tbh.
No it is an opinion, and IMHO the RoI for time invested in learning bash is far less than Python or Powershell.
$ bash
/bin/ksh: bash: not found
strike one... $ pkglocate powershell | grep \^power
$
strike two...Except I have no issues with other programming languages. Bash is really different. I only tolerate it because it comes pre-installed on just about every system.
I also have issues with COBOL.
Sometimes a language is just too inelegant to pour time into learning it.