31
submitted 4 days ago by Laser@feddit.org to c/linux@lemmy.ml
top 9 comments
sorted by: hot top controversial new old
[-] Trent@lemmy.ml 14 points 4 days ago
[-] Laser@feddit.org 4 points 4 days ago

Thanks, I never used it and had forgotten about it until now.

[-] double_quack@lemm.ee 1 points 3 days ago

Nice! I didn't know this

[-] StrangeAstronomer@lemmy.ml 6 points 4 days ago

venerable jq

Ha! jq was the bratty kid I yelled at to get off my lawn. Now he's a drinking buddy, but still the youngest!

[-] Laser@feddit.org 3 points 3 days ago

It's true that compared to the other utilities, it's rather new. First release was almost 13 years ago. awk, which I think is the closest comparison, on the other hand turns 50 in 2027... though new awk is only 40.

[-] traches@sh.itjust.works 3 points 3 days ago

Shout out to nushell for building an entire shell around this idea!

[-] Laser@feddit.org 2 points 3 days ago

It's a cool shell, I like ita lot more since I found out you can use ? to mark a field optional

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

A tradeoff between convenience and usecase. I personally would only use json/jq for complex data processing needs. But then i would use Python, not shell.

[-] Laser@feddit.org 2 points 3 days ago

The issue is not only complexity, though it does play a role. You can also run into issues with pure text parsing, especially when whitespace is involved. The IP thing is a very classic example in my opinion, and while whitespace might not be an issue there (more common with filenames), the queries you find online in my opinion aren't less complex.

Normal CLI output is often meant to be consumed by humans, so the data presentation requirements are different. Then you find out that an assumption you made isn't true (e.g. due to LANG indicating a non-English language) and suddenly your matching rules don't fit.

There are just a lot of pitfalls that can make things go subtly wrong, which is why parsing general CLI output that's not intended to be parsed is often advised against. It doesn't mean that it will go wrong.

Regarding Python, I think it has a place when you do what I'd call data set processing, while what I talk about is shell plumbing. They can both use JSON, but the tools are probably not the same.

this post was submitted on 03 May 2025
31 points (87.8% liked)

Linux

53962 readers
793 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS