{"username":"jdoe","password":"sec\\ret$"} EOF $ jq . ./credentials.json { "username": "jdoe", "password": "sec\\ret$" } \```


jq is the program to manipulate JSON in Bash. The most common use is to pull some information out of JSON files. It uses a filter language to manipulate the input. The simplest filter is the identity, . (a single full stop). This is similar to mathematical identity: the input becomes the output. Let’s create a file containing some non–trivial JSON and apply the identity filter to it:

The first command uses a quoted here document to save a string with special characters without having to escape them.


This page is a preview of The newline Guide to Bash Scripting

No discussions yet