4 ms·
...its the exact same damn thing. Parse text, put it into variables. PowerShell has the equivalent of all those same tools. The big difference is that you don'
by AnIdiotOnTheNet 4y ago
...its the exact same damn thing. Parse text, put it into variables. PowerShell has the equivalent of all those same tools.
The big difference is that you don't have to use them for every goddamned command.
- bheadmaster 4y ago> PowerShell has the equivalent of all those same tools. Really? What are the equivalents?
- majkinetor 4y agoSelect-String and Select-Object cover all those. Also, you can use linux tools in PowerShell, but that is not the point, it is back to stone age moment. Shell scripts shouldn't be other name for text parsing.
- bheadmaster 4y agoSelect-String covers grep (regex match) and Select-Object doesn't do anything for text parsing. You cannot use linux tools in PowerShell in most cases, since they aren't installed by default. > Shell scripts shouldn't be other name for text parsing. That may be true, but like any other ideal - it's just that, and ideal. In the real world a lot of shell scripting requires parsing unstructured text from various command outputs and files. PowerShell works great in its own microcosm of objects and commands that manipulate objects, but as soon as you step out of that comfort zone it becomes awkward to use.
- majkinetor 4y agoSelect-Object is for head/tail as poster mentioned that. Also, it can be used for accessing parsed content similar to awk, for example: '1,2,3,4,5' -split ',' | select -Index 3,5 > You cannot use linux tools in PowerShell in most cases, since they aren't installed by default. The same as jq and specific variants of tools you mention. Not like you can't install them in single line: winget/choco install awk,grep,jq,less... > In the real world a lot of shell scripting requires parsing unstructured text from various command outputs and files. No it doesn't. I do shell scripting for more then decade in PowerShell and I can count how many times I parsed the text. The most used one is simple split like with `$paths = $Env:PATH -split ';|:'`, but other then that no. I used select-string only couple of times in decade, on all OSes. > but as soon as you step out of that comfort zone it becomes awkward to use. That is true for literary anything. Actually pwsh does great with 'native' tools too, and there is even MS module to help with "native app wrapping". See [1] and [2] Today its more or less regular to have json output which can be trivially read by pwsh ConvertFrom-Json [1] https://devblogs.microsoft.com/powershell/native-commands-in-powershell-a-new-approach https://devblogs.microsoft.com/powershell/native-commands-in.... [2] https://redmondmag.com/articles/2020/12/11/powershell-crescendo-preview.aspx https://redmondmag.com/articles/2020/12/11/powershell-cresce...