4 ms·
Question for the more seasoned Mac/Linux folks on HN: Powershell has been a gift in getting things accomplished in Windows. But one thing I've also come to en
by agent86 4y ago
Question for the more seasoned Mac/Linux folks on HN:
Powershell has been a gift in getting things accomplished in Windows. But one thing I've also come to enjoy using it for is quick and dirty interactions and scripting with REST APIs.
Things like Invoke-WebRequest, ConvertTo-Json/ConvertFrom-Json, Export-CSV, piping between almost everything, and the results being passed around like an object that I can use SQL-ish Select queries against, etc.
I find myself feeling like I'm missing something helpful when I'm on a Mac/Linux device. Is there a similar go to in the Mac/Linux world for this type of stuff? My current thinking is that I either have to start picking up Python or building a mental map of wget/awk/grep type commands that can be chained together for a similar effect, but I thought it best to try to learn from the wisdom of others first :-)
- paramost 4y agoNot a seasoned mac/Linux user, but would powershell core not work? I believe it's cross platform?
- jhugo 4y agocurl, jq
- pouting 4y agoPowershell 7 is cross-platform.
- magospietato 4y agoIs there a similar go to in the Mac/Linux worlds? Yeah, it's called Powershell 7! Powershell was ported to cross platform dotnet a few years back. Currently running some Powershell scripts in production on a Linux box.
- rektide 4y ago"You can use powershell" isnt quite the same as asking what the open source world does. Adoption of powershell on Linux/Mac is tiny. If you show up on a random system, it almost certainly will not be available. It's good to know powershell is cross platform now. Good to know this can be an option. But I'd also say the original question still deserves more exploration & thought, that asking what the romans do in rome is good to know too.
- deleted 4y ago[deleted]
- ciupicri 4y agoThat random system might only have the dash shell and busybox. What are you going to do then?
- rektide 4y agoCurl, jq is the good answer here. More from the fringe, I'm quite enjoying zx, a really nodejs powered scripting environment. https://github.com/google/zx https://github.com/google/zx Covered somewhat in ZX 3.0 https://news.ycombinator.com/item?id=28195580 https://news.ycombinator.com/item?id=28195580 (189 points, 8 months ago, 163 points)
- jiggawatts 4y agoThese are only vaguely comparable. It’s like saying assembly language is a substitute for something elegant in Haskell. Technically true in some sense, but not really.
- rektide 4y agoZx really intends to be a scripting language (and i think it does a good job) that happens to be javascript. Personally I feel like thenbiggest missing piece ZX would beed to be a good straight up competitor to bash or zsh would be better interactive modes. A node repl.os ok, uses libreadline & has lots.of capabilities, but zx feels biased towards scripting, not am actual shell. I dont see why you think zx couldnt be a substitute. Particularly & especially in the context of a discussion on powershell, where we are clearly already opening the gates of heterodoxy already.
- jiggawatts 4y agoOne of the other responses mentioned Nushell, which is a direct substitute for PowerShell in a meaningful sense: an interactive shell, structured pipelines, formatting as the final step of a pipeline, etc... Anything else tends to be either a random bag of unrelated tools sticky-taped together, OR a heavyweight programming language. The equivalent of JavaScript or Python is C#, CS-Script, or F# Interactive. Those are also full-featured programming languages. I can process files in just a couple of lines of C#, but I still reach for PowerShell when doing this kind of thing unless I really need higher throughputs or complex processing.
- 4y ago
- closeparen 4y agoThis is the fundamental differentiation of Powershell, right? UNIX operates on text streams while Powershell operates on structured data. It is in a better position to do this kind of stuff. That aside, a lot of contemporary cloudy CLIs will now speak json on stdin/out and JQ will make any json transformations you can imagine.
- sjellis 4y agoThere are a few projects that take inspiration from PowerShell, but they haven't got mass adoption. I have hopes that Nushell will be a success when it gets to 1.0: https://www.nushell.sh/ https://www.nushell.sh/
- digisign 4y agoYes, you can use Python just about anywhere, and it is arguably more sane/readable. Prefer httpie over curl at the command-line as well.