Except with Bash it really isn't worth it. Learning PowerShell is much better for long scripts.
Except with Bash it really isn't worth it. Learning PowerShell is much better for long scripts.
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...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.