this post was submitted on 03 May 2025
16 points (94.4% liked)

Linux

10226 readers
217 users here now

Welcome to c/linux!

Welcome to our thriving Linux community! Whether you're a seasoned Linux enthusiast or just starting your journey, we're excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let's dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!

Rules:

  1. Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.

  2. Be respectful: Treat fellow community members with respect and courtesy.

  3. Quality over quantity: Share informative and thought-provoking content.

  4. No spam or self-promotion: Avoid excessive self-promotion or spamming.

  5. No NSFW adult content

  6. Follow general lemmy guidelines.

founded 2 years ago
MODERATORS
 

In this post, I go into hopefully better output parsing.

top 11 comments
sorted by: hot top controversial new old
[–] JWBananas@lemmy.world 8 points 3 days ago (2 children)

Mom: We have PowerShell at home.

[–] catloaf@lemm.ee 1 points 3 days ago (1 children)

You can run powershell on Linux! This is the one thing I like about powershell: everything's an object under the hood.

[–] toastmeister@lemmy.ca 1 points 2 days ago* (last edited 2 days ago)

Is that why my if statements don't work properly?

[–] Laser@feddit.org 0 points 3 days ago (1 children)

Linux also has some shells working on structured data (e.g. nu and elvish). But those don't really help you on machines that don't have those installed.

In general, I think Powershell's approach is better than the traditional one, but I really dislike the general commands. Always feels weird using it.

[–] JWBananas@lemmy.world 3 points 3 days ago (1 children)

But those don't really help you on machines that don't have those installed.

Meanwhile the article assumes jq is present, which it hasn't been by default on any of my servers.

Off I go down the structured data shells for Linux rabbit hole!

[–] Laser@feddit.org 3 points 3 days ago (1 children)

Maybe I should have written it differently: I think people are rather willing to install another tool than a whole new shell. The later would also require you to fundamentally change your scripts, because that's most often where you need that carefully extracted data. Otherwise manually copying and pasting would suffice.

I was thinking about writing a post about nu as well. But I wasn't sure that appeals to many, or is it should be part of something like a collection of stuff I like, together with fish as an example of a more traditional shell.

[–] chonkyninja@lemmy.world 0 points 3 days ago (1 children)

Maybe you should just learn the toolsets better. Structured looks great until you’re tasked either with parsing a 20GB structured file. Each line of text representing a single item in a collection makes total sense, then when you get into things like a list subtype there’s nothing stopping you from using a char sequence to indicate a child item.

[–] Laser@feddit.org 4 points 3 days ago

One might wonder if at those file sizes, working with text still makes sense. I think there's a good reason journald uses a binary format for storing all that data. And "real" databases tend to scale better than text files in a filesystem as well, even though a filesystem is a database.

Most people won't have to deal with that amount of text based data ever.

[–] dengtav@lemmy.ml 5 points 3 days ago* (last edited 3 days ago) (1 children)

Isn't it incredible, that we have to read blogposts to learn how to extract an IP addr of a network interface in the shell ... in json ... in 2025 ??!

Some problems will never really get solved.

Thanks for the write up !

[–] Laser@feddit.org 2 points 3 days ago* (last edited 3 days ago) (1 children)

You're welcome! And actually, even this approach can yield surprising results... As in have you heard of deprecated IPv6 addresses before? Well I hadn't until I realized my interface now had one (it actually didn't anymore when I wrote the post, I used the jq command on old output, not in a pipe). Which made my DynDNS script stop working because there was now a line break in the request URL that curl rightfully failed on.

Edit: also despite what the title of the post says, in not an authoritative expert on the matter and you can use whatever works for you. I see these posts more as a basis for discussions like here than definitive guides to do something the correct way.

[–] dengtav@lemmy.ml 2 points 3 days ago* (last edited 3 days ago)

As in have you heard of deprecated IPv6 addresses before?

Definetly not 0.o

It's really hard to actually believe that a problem like this hasn't got a 1-word-command + flag solution yet. I mean you could ecxpect something like

ip -6 -i eno0

or so...

And yes, totally agree on the edit part! It's always nice to at least no about all the options that exist and smb found out hustling the same struggle like me :D