Skip to content

Instantly share code, notes, and snippets.

@zouppen
Created September 1, 2022 22:42
Show Gist options
  • Save zouppen/1b9f25c2237da3ad0a0c6a3209068d19 to your computer and use it in GitHub Desktop.
Save zouppen/1b9f25c2237da3ad0a0c6a3209068d19 to your computer and use it in GitHub Desktop.
A compact example how to convert rows to JSON objects in shell & jq
#!/bin/sh -eu
export ydin=`uname -r`
export os=`uname`
lspci | jq -Rs '{os: env.os, ver: env.ydin, laitteet: split("\n") | map(capture("^[^ ]* (?<key>[^:]*): (?<value>.*)$") ) | from_entries}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment