jc

From RaySoft

jc converts the output of many standard unix command line tools and file-types to dictionaries and lists of dictionaries. [1]

Documentation

Further Information

Syntax

COMMAND | jc [PARAMETER ...] PARSER
jc [PARAMETER ...] COMMAND

Parameters

-p
Pretty format the JSON output.
-q
Quiet mode. Suppresses warning messages.
-r
Raw output. Provides a more literal JSON output with all values as text and no additional sematic processing

Parsers

--arp
Enables the arp command parser.
--crontab
Enables the crontab command and file parser.
--crontab-u
Enables the crontab file parser with user support.
--df
Enables the df command parser.
--dig
Enables the dig command parser.
--du
Enables the du command parser.
--env
Enables the env command parser.
--free
Enables the free command parser.
--fstab
Enables the /etc/fstab file parser.
--history
Enables the history command parser.
--hosts
Enables the /etc/hosts file parser.
--id
Enables the id command parser.
--ifconfig
Enables the ifconfig command parser.
--ini
Enables the INI file parser.
--iptables
Enables the iptables command parser.
--jobs
Enables the jobs command parser.
--ls
Enables the ls command parser.
--lsblk
Enables the lsblk command parser.
--lsmod
Enables the lsmod command parser.
--lsof
Enables the lsof command parser.
--mount
Enables the mount command parser.
--netstat
Enables the netstat command parser.
--pip-list
Enables the pip list command parser.
--pip-show
Enables the pip show command parser.
--ps
Enables the ps command parser.
--route
Enables the route command parser.
--ss
Enables the ss command parser.
--stat
Enables the stat command parser.
--systemctl
Enables the systemctl command parser.
--systemctl-lj
Enables the systemctl list-jobs command parser.
--systemctl-ls
Enables the systemctl list-sockets command parser.
--systemctl-luf
Enables the systemctl list-unit-files command parser.
--uname
Enables the uname -a command parser.
--uptime
Enables the uptime command parser.
--w
Enables the w command parser.
--xml
Enables the XML file parser.
--yaml
Enables the YAML file parser.

Examples

Convert the ARP cache list to JSON with jc, remove some attributes and output it nicely with jq
arp -a | jc --arp | jq 'del(.[].name, .[].permanent)'

Output:

[
  {
    "address": "10.0.0.1",
    "hwtype": "ethernet",
    "hwaddress": "0:0:5e:0:1:1",
    "iface": "en9"
  },
  {
    "address": "10.0.0.6",
    "hwtype": "ethernet",
    "hwaddress": "b8:69:f4:1:70:b1",
    "iface": "en9"
  }
]

References

  1. Repository contributors. "jc." GitHub. https://github.com/kellyjonbrazil/jc/tree/master/docs (accessed 05.05.2023)