1
0
mirror of https://github.com/jlevy/the-art-of-command-line.git synced 2024-12-04 10:24:46 +02:00

One-liner to show colored, normalized JSON diffs.

This commit is contained in:
Joshua Levy 2019-05-27 15:27:37 -07:00 committed by GitHub
parent 3d8afef22e
commit 84482aa24d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -364,6 +364,11 @@ A few examples of piecing together commands:
sort a b b | uniq -u > c # c is set difference a - b
```
- Pretty-print two JSON files, normalizing their syntax, then coloring and paginating the result:
```
diff <(jq --sort-keys . < file1.json) <(jq --sort-keys . < file2.json) | colordiff | less -R
```
- Use `grep . *` to quickly examine the contents of all files in a directory (so each line is paired with the filename), or `head -100 *` (so each file has a heading). This can be useful for directories filled with config settings like those in `/sys`, `/proc`, `/etc`.