3 ms·
The first thing you should learn with PowerShell are the discoverability features: Tab completion, Get-help, get-command, show-command, get-member, get-alias.
by 13of40 11y ago
The 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.
- pritambaral 11y agoMemorization is a necessity in every endeavour involving a process, even a computer is nothing without some form of memory. Like you remember powershell commands and switches and whatnot, I remember where executables are placed. It may be a convention, but that's only because a restriction hasn't been placed (yay, freedom?); for all practical purposes, it is a rule. Crossing fingers and hoping devs have followed a rule/convention/sensibility happens everywhere that isn't 100% under one's own control. Like I have to cross my fingers when installing from an .exe or .msi. > I'm guessing there is no solid convention for parsing a manpage to ... You guess wrong. (There is no convention for parsing a manpage, only for writing one, but isn't that enough?) > Everything above is tab-completable So it is in the *nix world. Check out oh-my-zsh (if bash's tab-completion wasn't enough for you), it has an option to enable a ridiculous (and annoying, IMO) amount of tab-completion.