5 ms·
I guess the difference between bash scripting and powershell scripting is that you have to learn a lot of things upfront to be productive with Powershell. Bash,
by simula67 11y ago
I guess the difference between bash scripting and powershell scripting is that you have to learn a lot of things upfront to be productive with Powershell. Bash, on the other hand, with its simpler syntax and collection of text based utilities you can get productive pretty quickly. If you want more power or if you want cleaner code you can always switch to Python et al. Thus, the learning curve is much more gentle. The latter embodies tinkering spirit and self-learning and the former shows its enterprise nature.
- 13of40 11y agoThe first thing you should learn with PowerShell are the discoverability features: Tab completion, Get-help, get-command, show-command, get-member, get-alias. Last time I checked (and admittedly it's been a few years) bash has man pages and that's it.
- dr_zoidberg 11y agoI agree with you (was about to post something similar), and wanted to add that some unix commands (which become part of the soul of bash scripts), are sometimes named in weird, unintuitive ways. For one thing, one potentially dangerous command is simply called "dd", and its man page[0] says next to nothing at all about its true power, uses and danger. [0] http://linux.die.net/man/1/dd http://linux.die.net/man/1/dd
- Karunamon 11y agoI don't think it's dd itself that's dangerous, rather the fact that it's usage is often paired with root access to raw device nodes on the filesystem. Even innocuous things like tee, cat, and bash output redirection can mess up your system if you blast something into /dev/sda.
- dr_zoidberg 11y agoIndeed, without root access you don't get to screw a disk with dd. But let's also admit that saying dd is a tool for copying files is a bit like saying that with a katana sword you can slice pizza... Technically true, but you're likely to get hurt in the process.
- pritambaral 11y agoHaven't used PS much – only used DuckDuckGo to find what each PS command meant, so it's possible I have misuderstood some, but – these are the bash alternatives, I think: | :PowerShell | Bash: | |Tab completion | built-in, OOTB| |Get-help | `help`| |get-command | `apropos -s <section> .`| |show-command | `<command> --help` or `man <command>`| |get-member | Inapplicable; text has a structure. Use `head -1` to find out, given structure is printed on first line | |get-alias | `alias`|
- 13of40 11y agoWhat's the bash equivalent of something like this? Get-Command -Module SQLPS | ?{$_.Parameters.Values.ParameterType -contains [PSCredential]} In PowerShell, this means "show me all the commands from the SQLPS module that take a credential object as one of the parameters".
- pritambaral 11y agoThis question weighs to powershell's side, and I wouldn't call it fair (and not just because I don't know powershell), but I'll bite. Print all files in package: `dpkg -L <package name>` (for Debian based OSes) Filter executable commands: ` | grep 'bin/.'` (assuming the package adheres to standards) Check parameters of command: `<command> --help` (again, assuming the developers have adhered to convention) Of course, if one needs to check multiple commands, one will have to use a loop. (Which is basic programming, isn't it?).
- latkin 11y ago"Which commands from XYZ package require credentials?" hardly seems unfair. Your suggestion solutions illustrate the point well - you have to memorize some convention of where utils are located, how they display usage info, then cross your fingers and hope developers have followed it. And it's not even complete, since I'm guessing there is no solid convention for parsing a manpage to find which args represent credentials. In powershell, cmdlets and their args are typed, so you just ask for all cmdlets that have an arg with the credential type. Everything above is tab-completable, too, and thus discoverable at least to some level.