1jc(1) JSON CLI output utility jc(1)
2
3
4
6 jc - JSONifies the output of many CLI tools and file-types
7
9 COMMAND | jc PARSER [OPTIONS]
10
11 or "Magic" syntax:
12
13 jc [OPTIONS] COMMAND
14
15
17 jc JSONifies the output of many CLI tools and file-types for easier
18 parsing in scripts. jc accepts piped input from STDIN and outputs a
19 JSON representation of the previous command's output to STDOUT. Alter‐
20 natively, the "Magic" syntax can be used by prepending jc to the com‐
21 mand to be converted. Options can be passed to jc immediately before
22 the command is given. (Note: "Magic" syntax does not support shell
23 builtins or command aliases)
24
25
27 Parsers:
28
29
30
31 --acpi `acpi` command parser
32
33
34 --airport
35 `airport -I` command parser
36
37
38 --airport-s
39 `airport -s` command parser
40
41
42 --arp `arp` command parser
43
44
45 --blkid
46 `blkid` command parser
47
48
49 --cksum
50 `cksum` and `sum` command parser
51
52
53 --crontab
54 `crontab` command and file parser
55
56
57 --crontab-u
58 `crontab` file parser with user support
59
60
61 --csv CSV file parser
62
63
64 --date `date` command parser
65
66
67 --df `df` command parser
68
69
70 --dig `dig` command parser
71
72
73 --dir `dir` command parser
74
75
76 --dmidecode
77 `dmidecode` command parser
78
79
80 --dpkg-l
81 `dpkg -l` command parser
82
83
84 --du `du` command parser
85
86
87 --env `env` command parser
88
89
90 --file `file` command parser
91
92
93 --finger
94 `finger` command parser
95
96
97 --free `free` command parser
98
99
100 --fstab
101 `/etc/fstab` file parser
102
103
104 --group
105 `/etc/group` file parser
106
107
108 --gshadow
109 `/etc/gshadow` file parser
110
111
112 --hash `hash` command parser
113
114
115 --hashsum
116 hashsum command parser (`md5sum`, `shasum`, etc.)
117
118
119 --hciconfig
120 `hciconfig` command parser
121
122
123 --history
124 `history` command parser
125
126
127 --hosts
128 `/etc/hosts` file parser
129
130
131 --id `id` command parser
132
133
134 --ifconfig
135 `ifconfig` command parser
136
137
138 --ini INI file parser
139
140
141 --iptables
142 `iptables` command parser
143
144
145 --iw-scan
146 `iw dev [device] scan` command parser
147
148
149 --jobs `jobs` command parser
150
151
152 --kv Key/Value file parser
153
154
155 --last `last` and `lastb` command parser
156
157
158 --ls `ls` command parser
159
160
161 --lsblk
162 `lsblk` command parser
163
164
165 --lsmod
166 `lsmod` command parser
167
168
169 --lsof `lsof` command parser
170
171
172 --mount
173 `mount` command parser
174
175
176 --netstat
177 `netstat` command parser
178
179
180 --ntpq `ntpq -p` command parser
181
182
183 --passwd
184 `/etc/passwd` file parser
185
186
187 --ping `ping` and `ping6` command parser
188
189
190 --pip-list
191 `pip list` command parser
192
193
194 --pip-show
195 `pip show` command parser
196
197
198 --ps `ps` command parser
199
200
201 --route
202 `route` command parser
203
204
205 --rpm-qi
206 `rpm -qi` command parser
207
208
209 --shadow
210 `/etc/shadow` file parser
211
212
213 --ss `ss` command parser
214
215
216 --stat `stat` command parser
217
218
219 --sysctl
220 `sysctl` command parser
221
222
223 --systemctl
224 `systemctl` command parser
225
226
227 --systemctl-lj
228 `systemctl list-jobs` command parser
229
230
231 --systemctl-ls
232 `systemctl list-sockets` command parser
233
234
235 --systemctl-luf
236 `systemctl list-unit-files` command parser
237
238
239 --systeminfo
240 `systeminfo` command parser
241
242
243 --time `/usr/bin/time` command parser
244
245
246 --timedatectl
247 `timedatectl status` command parser
248
249
250 --tracepath
251 `tracepath` and `tracepath6` command parser
252
253
254 --traceroute
255 `traceroute` and `traceroute6` command parser
256
257
258 --ufw `ufw status` command parser
259
260
261 --ufw-appinfo
262 `ufw app info [application]` command parser
263
264
265 --uname
266 `uname -a` command parser
267
268
269 --upower
270 `upower` command parser
271
272
273 --uptime
274 `uptime` command parser
275
276
277 --w `w` command parser
278
279
280 --wc `wc` command parser
281
282
283 --who `who` command parser
284
285
286 --xml XML file parser
287
288
289 --yaml YAML file parser
290
291
292
293 Options:
294
295
296 -a about jc (JSON output)
297
298 -d debug - show traceback (-dd for verbose traceback)
299
300 -h help (-h --parser_name for parser documentation)
301
302 -m monochrome output
303
304 -p pretty print output
305
306 -q quiet - suppress warnings
307
308 -r raw JSON output
309
310 -v version information
311
312
314 Any fatal errors within jc will generate an exit code of 100, otherwise
315 the exit code will be 0. When using the "Magic" syntax (e.g. jc ifcon‐
316 fig eth0), jc will store the exit code of the program being parsed and
317 add it to the jc exit code. This way it is easier to determine if an
318 error was from the parsed program or jc.
319
320 Consider the following examples using `ifconfig`:
321
322 ifconfig exit code = 0, jc exit code = 0, combined exit code = 0
323 (no errors)
324
325 ifconfig exit code = 1, jc exit code = 0, combined exit code = 1
326 (error in ifconfig)
327
328 ifconfig exit code = 0, jc exit code = 100, combined exit code =
329 100 (error in jc)
330
331 ifconfig exit code = 1, jc exit code = 100, combined exit code =
332 101 (error in both ifconfig and jc)
333
334
336 You can specify custom colors via the JC_COLORS environment variable.
337 The JC_COLORS environment variable takes four comma separated string
338 values in the following format:
339
340 JC_COLORS=<keyname_color>,<keyword_color>,<number_color>,<string_color>
341
342 Where colors are: black, red, green, yellow, blue, magenta, cyan, gray,
343 brightblack, brightred, brightgreen, brightyellow, brightblue, bright‐
344 magenta, brightcyan, white, or default
345
346 For example, to set to the default colors:
347
348 JC_COLORS=blue,brightblack,magenta,green
349
350 or
351
352 JC_COLORS=default,default,default,default
353
354
356 Custom local parser plugins may be placed in a jc/jcparsers folder in
357 your local "App data directory":
358
359 - Linux/unix: $HOME/.local/share/jc/jcparsers
360
361 - macOS: $HOME/Library/Application Support/jc/jcparsers
362
363 - Windows: $LOCALAPPDATA\jc\jc\jcparsers
364
365 Local parser plugins are standard python module files. Use the
366 jc/parsers/foo.py parser as a template and simply place a .py file in
367 the jcparsers subfolder.
368
369 Local plugin filenames must be valid python module names, therefore
370 must consist entirely of alphanumerics and start with a letter. Local
371 plugins may override default plugins.
372
373 Note: The application data directory follows the XDG Base Directory
374 Specification
375
376
378 Locale: For best results set the LANG locale environment variable to C
379 or en_US.UTF-8. For example, either by setting directly on the command-
380 line:
381
382 $ LANG=C date | jc --date
383
384 or by exporting to the environment before running commands:
385
386 $ export LANG=C
387
388 Timezones: Some parsers have calculated epoch timestamp fields added to
389 the output. Unless a timestamp field name has a _utc suffix it is con‐
390 sidered naive. (i.e. based on the local timezone of the system the jc
391 parser was run on).
392
393 If a UTC timezone can be detected in the text of the command output,
394 the timestamp will be timezone aware and have a _utc suffix on the key
395 name. (e.g. epoch_utc) No other timezones are supported for aware time‐
396 stamps.
397
398
400 Standard Syntax:
401 $ dig www.google.com | jc --dig -p
402
403 Magic Syntax:
404 $ jc -p dig www.google.com
405
406 For parser documentation:
407 $ jc -h --dig
408
410 Kelly Brazil (kellyjonbrazil@gmail.com)
411
412 https://github.com/kellyjonbrazil/jc
413
414
416 Copyright (c) 2019-2021 Kelly Brazil
417
418 License: MIT License
419
420
421
4221.15.5 2021-05-27 jc(1)