>For example, if we wanted to get the first three files from ls I’d do something like `ls | head -n 3`. In Powershell, it’s `$(dir)[0..2]` since the dir command is returning an array which I can index into. You could do that, but the way to write it in the bash way would be `dir | select -first 3` >a quick Google told me to use `echo | openssl s_client -showcerts -servername joejag.com -connect joejag.com:443 2>/dev/…
> You could do that, but the way to write it in the bash way would be `dir | select -first 3` I would have said "ls | head -n3" as well. I've never heard of "select". I just tried your suggestion and it doesn't appear to work: $ dir | select -first 3 bash: syntax error near unexpected token `3'
Two Months with Powershell on a Unix
61–70 of 113 posts
Re: Two Months with Powershell on a Unix
#62>For example, if we wanted to get the first three files from ls I’d do something like `ls | head -n 3`. In Powershell, it’s `$(dir)[0..2]` since the dir command is returning an array which I can index into. You could do that, but the way to write it in the bash way would be `dir | select -first 3` >a quick Google told me to use `echo | openssl s_client -showcerts -servername joejag.com -connect joejag.com:443 2>/dev/…
>You could do that, but the way to write it in the bash way would be `dir | select -first 3` Fyi, `dir | select -first 3` also works in PowerShell.
Re: Two Months with Powershell on a Unix
#63I like that it passes objects instead of strings, I could see that being really useful. Get-Member will list all methods and properties of an object.
Re: Two Months with Powershell on a Unix
#64I am dead serious. Powershell should replace (bash) shell scripting under any Linux. I find shell scripts terrible, I've learned to switch to Python quickly, despite the overhead. Powershell is very command-line friendly, with easy tab-completion of commands. I've worked with it extensively on Windows, creating large worklflows with it, it's very nice. Powershell even has a unit test tool called 'pester' which is fun…
Re: Two Months with Powershell on a Unix
#65The story goes on like this:
You went to DataCentre, logged in to an internal machine, something happened (eg failure, diagnostic necessary et.al.) which you need to fix.
given condition, you don't have internet connection inside (air-gapped)
- You most likely have man-pages installed and having examples what to do in them,
- `--help` yields some sensible output
- Shell is 'fast', errors are well-known and defined.
Also, take into account of other comments that are discussing `how to do x` and why it doesn't/wouldn't work on PowerShell
Re: Two Months with Powershell on a Unix
#66Earlier quoted context omitted.
>You could do that, but the way to write it in the bash way would be `dir | select -first 3` Fyi, `dir | select -first 3` also works in PowerShell.
Yes, this is what the parent meant: it is valid PowerShell. It wouldn't work by default in Bash unless you had `dir` and `select` defined there somehow.
Re: Two Months with Powershell on a Unix
#67Re: Two Months with Powershell on a Unix
#68Re: Two Months with Powershell on a Unix
#69I spent some time with Powershell on Windows recently, more time than I am used to. Powershell is a clear winner over CMD.EXE by a mile, but… - As an interactive shell, it suffers from an ecosystem which is much poorer than the bash/zsh ecosystem, - As a scripting language, I’m going to use Python or Go the moment anything becomes larger than a few lines, - Installing Posh Git is just a really mediocre experience (in…
My biggest issue with powershell is how undiscoverable it is. Good luck doing anything without searching for commands in a web browser. But maybe that's just a result if it being so new. 'ls' has been around for almost 50 years... What it really feels like is a complete programming language inside of notepad.exe because of the historically terrible windows command prompt.
It takes loads of reading and trial and error to become competent in any command line.
Re: Two Months with Powershell on a Unix
#70I am dead serious. Powershell should replace (bash) shell scripting under any Linux. I find shell scripts terrible, I've learned to switch to Python quickly, despite the overhead. Powershell is very command-line friendly, with easy tab-completion of commands. I've worked with it extensively on Windows, creating large worklflows with it, it's very nice. Powershell even has a unit test tool called 'pester' which is fun…
If you have to write shell scripts on Linux then target #!/bin/sh and write it so that it works in other shells.
The problem with Powershell for scripting is that it is just good enough that people don't go use something better like Python or Ruby.