3 ms·
PowerShell is a lot better at this. It was designed for reading by humans, not for saving precious bytes over 300-baud terminal connections. So for example, se
by jiggawatts 7y ago
PowerShell is a lot better at this. It was designed for reading by humans, not for saving precious bytes over 300-baud terminal connections.
So for example, selecting columns is easy, and can be done by name.
Here's a useful little snippet demonstrating converting and processing the CSV output of the legacy "whoami" Windows command. It lists the groups a user is a member of without poking domain controllers using LDAP. It always works, including cross-forest scenarios.
WHOAMI /GROUPS /FO CSV `
| ConvertFrom-Csv `
| Where-Object Attributes -NotLike '*used for deny only*' `
| Select-Object -ExpandProperty 'Group Name'
It looks like a lot of typing, but everything tab-completes and the end-result is human readable. I find that people that prefer terseness over verbose syntax are selfish. They simply don't care about the future maintainers of their scripts.
PowerShell can also natively parse JSON and XML into object hierarchies and then select from them. That's difficult in UNIX. The Invoke-RestMethod command is particularly brilliant, because instead of a stream of bytes it returns an object that can be manipulated directly.
$p = Invoke-RestMethod 'https://ipapi.co/8.8.8.8/json/'
echo $p.org
echo $p.country_name
PowerShell Core is available on Linux and is great for ad-hoc tabular data processing! Give it a go...
- LilBytes 7y agoPowerShell Core (PS5/open source) is crushing it in this space over Bash\AWK specifically. I'm a pretty advocate for how it works in these use cases now. Generally I still use Bash\Sed\AWK for the one off instances when ever I need something done there and then. But if I'm writing something that's going to be involved in my CI\CD with a high chance of needing to be maintained. I'll nearly always write it in PowerShell.
- shiftless 7y agoSorry, the reason I moved to OpenBSD and Linux From Scratch was to avoid getting sucked into the dark gaping asshole of Lucifer. Microsoft shitware is not allowed on my system. Does the phrase "Embrace, Extend, Extinguish" ring a bell? Between RedHat, Ubuntu, and Poettering (in no particular order), they have already done great damage to the world of Linux. Microsoft, needless to say, is a cancer. > I find that people that prefer terseness over verbose syntax are selfish. They simply don't care about the future maintainers of their scripts. Nor do you, apparently, since the poor souls who follow in your footsteps will invariably be stuck within the literal hell on earth that is the Microsoft ecosystem. Enjoy your regularly scheduled malware updates.