Re:Learning modern Linux: A handbook for the cloud native pr...
by Mister_Snuggles on Saturday May 07, 2022 @07:04PM
(#31299474)
FreeBSD has integrated libxo[0] into a lot of its base utilities, so you can use something like `netstat --libxo json` to get structured data that can be sliced and diced with other tools. Unfortunately, it hasn't been extended to all of the base system yet (ls, for example, doesn't support libxo output).
For example:
$ w --libxo json|json_pp
{
"uptime-information" : {
"days" : 46,
"hours" : 22,
"load-average-1" : 0.19,
"load-average-15" : 0.13,
"load-average-5" : 0.12,
"minutes" : 11,
"seconds" : 34,
[...]
Obviously it's not as extensive as PowerShell, but it definitely gets rid of screen-scraping.[0] https://www.freebsd.org/cgi/man.cgi?query=libxo&sektion=3&fo...
Re:Learning modern Linux: A handbook for the cloud native pr...
by GekkePrutser on Saturday May 07, 2022 @07:07PM
(#31299495)
Ooh this is really cool, thanks for sharing. FreeBSD is actually my daily driver so that'll really come in handy.
Re:Learning modern Linux: A handbook for the cloud native pr...
by d0mine on Sunday May 08, 2022 @12:51PM
(#31305735)
Actually, it is a step backwards: unless you control both sides (perfect version compatibility), passing text to extract only parts you care about is more resilient (think SOAP vs. REST).
I still don't use it on Linux but I do think it's a big step forward for scripting.