by stackedinserter · 1y ago · 0 comments
(curl http://localhost:5555/log | grep -o -E "2025[0-9-]+")
(Invoke-WebRequest -Uri "http://localhost:5555/log" -UseBasicParsing).Content | Select-String -Pattern "2025[0-9-]+" -AllMatches | ForEach-Object { $_.Matches.Value }
or this (ps ax | grep ffmpeg) Get-Process | Where-Object { $_.ProcessName -match "ffmpeg" }
Maybe it's good for scripting (why not python then?) but really sucks when you need to get things done in terminal. $ ps ax | grep ffmpeg
66898 pe S+p 0:00.01 grep ffmpeg
$ ps ax | grep '[f]fmpeg'
$ pgrep ffmpeg
$
As for PowerShell, it does not seem useful, but then again I live mostly on OpenBSD and in the terminal.The way to write that on the command line Powershell would be:
ps ffmpeg
Whereas your longer example is what you put in the PS1 file.It also has positional parameters meaning you don't have to specify parameter names, though you might as well because tab completion is a thing. And if you're really keen on not using tab completion, it autocompletes parameter names for you meaning "get-help man -e" is equivalent to "get-help man -examples".
Here are less verbose posh commands for your examples.
(curl http://localhost:555/log -useb | select content | sls "2025[0-9-]+" -a).select.matches
Still arguably a mess. Select-string not having a -o equivalent parameter is a big gripe of mine. (gps ffmpeg) or (ps ffmpeg)
Get-Process has a name parameter. Why not use it?Edit:
I should have added, curl ships with Windows now so a farer comparison would be a select-string on curl.exe.
Auto complete is quite good though.