@@ -104,74 +104,58 @@ sections:
104
104
You can affect how jq reads and writes its input and output
105
105
using some command-line options:
106
106
107
- * `--version`/`-V `:
107
+ * `--null-input` / `-n `:
108
108
109
- Output the jq version and exit with zero.
110
-
111
- * `--seq`:
112
-
113
- Use the `application/json-seq` MIME type scheme for separating
114
- JSON texts in jq's input and output. This means that an ASCII
115
- RS (record separator) character is printed before each value on
116
- output and an ASCII LF (line feed) is printed after every
117
- output. Input JSON texts that fail to parse are ignored (but
118
- warned about), discarding all subsequent input until the next
119
- RS. This mode also parses the output of jq without the `--seq`
120
- option.
121
-
122
- * `--stream`:
123
-
124
- Parse the input in streaming fashion, outputting arrays of path
125
- and leaf values (scalars and empty arrays or empty objects).
126
- For example, `"a"` becomes `[[],"a"]`, and `[[],"a",["b"]]`
127
- becomes `[[0],[]]`, `[[1],"a"]`, and `[[2,0],"b"]`.
128
-
129
- This is useful for processing very large inputs. Use this in
130
- conjunction with filtering and the `reduce` and `foreach` syntax
131
- to reduce large inputs incrementally.
132
-
133
- * `--stream-errors`:
134
-
135
- Like `--stream`, but invalid JSON inputs yield array values
136
- where the first element is the error and the second is a path.
137
- For example, `["a",n]` produces ["Invalid literal at line 1,
138
- column 9",[1]]`.
139
-
140
- Implies `--stream`. Invalid JSON inputs produce no error values
141
- when `--stream` without `--stream-errors`.
142
-
143
- * `--slurp`/`-s`:
144
-
145
- Instead of running the filter for each JSON object in the
146
- input, read the entire input stream into a large array and run
147
- the filter just once.
109
+ Don't read any input at all. Instead, the filter is run once
110
+ using `null` as the input. This is useful when using jq as a
111
+ simple calculator or to construct JSON data from scratch.
148
112
149
- * `--raw-input`/ `-R`:
113
+ * `--raw-input` / `-R`:
150
114
151
115
Don't parse the input as JSON. Instead, each line of text is
152
116
passed to the filter as a string. If combined with `--slurp`,
153
117
then the entire input is passed to the filter as a single long
154
118
string.
155
119
156
- * `--null-input`/`-n `:
120
+ * `--slurp` / `-s `:
157
121
158
- Don't read any input at all! Instead, the filter is run once
159
- using `null` as the input. This is useful when using jq as a
160
- simple calculator or to construct JSON data from scratch .
122
+ Instead of running the filter for each JSON object in the
123
+ input, read the entire input stream into a large array and run
124
+ the filter just once .
161
125
162
126
* `--compact-output` / `-c`:
163
127
164
128
By default, jq pretty-prints JSON output. Using this option
165
129
will result in more compact output by instead putting each
166
130
JSON object on a single line.
167
131
168
- * `--tab `:
132
+ * `--raw-output` / `-r `:
169
133
170
- Use a tab for each indentation level instead of two spaces.
134
+ With this option, if the filter's result is a string then it
135
+ will be written directly to standard output rather than being
136
+ formatted as a JSON string with quotes. This can be useful for
137
+ making jq filters talk to non-JSON-based systems.
171
138
172
- * `--indent n `:
139
+ * `--join-output` / `-j `:
173
140
174
- Use the given number of spaces (no more than 7) for indentation.
141
+ Like `-r` but jq won't print a newline after each output.
142
+
143
+ * `--nul-output` / `-0`:
144
+
145
+ Like `-r` but jq will print NUL instead of newline after each output.
146
+ This can be useful when the values being output can contain newlines.
147
+
148
+ * `--ascii-output` / `-a`:
149
+
150
+ jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
151
+ if the input specified them as escape sequences (like
152
+ "\u03bc"). Using this option, you can force jq to produce pure
153
+ ASCII output with every non-ASCII character replaced with the
154
+ equivalent escape sequence.
155
+
156
+ * `--sort-keys` / `-S`:
157
+
158
+ Output the fields of each object with the keys in sorted order.
175
159
176
160
* `--color-output` / `-C` and `--monochrome-output` / `-M`:
177
161
@@ -184,69 +168,63 @@ sections:
184
168
Colors can be configured with the `JQ_COLORS` environment
185
169
variable (see below).
186
170
187
- * `--binary` / `-b `:
171
+ * `--tab `:
188
172
189
- Windows users using WSL, MSYS2, or Cygwin, should use this option
190
- when using a native jq.exe, otherwise jq will turn newlines (LFs)
191
- into carriage-return-then-newline (CRLF).
173
+ Use a tab for each indentation level instead of two spaces.
192
174
193
- * `--ascii-output` / `-a `:
175
+ * `--indent n `:
194
176
195
- jq usually outputs non-ASCII Unicode codepoints as UTF-8, even
196
- if the input specified them as escape sequences (like
197
- "\u03bc"). Using this option, you can force jq to produce pure
198
- ASCII output with every non-ASCII character replaced with the
199
- equivalent escape sequence.
177
+ Use the given number of spaces (no more than 7) for indentation.
200
178
201
179
* `--unbuffered`:
202
180
203
181
Flush the output after each JSON object is printed (useful if
204
182
you're piping a slow data source into jq and piping jq's
205
183
output elsewhere).
206
184
207
- * `--sort-keys` / `-S `:
185
+ * `--stream `:
208
186
209
- Output the fields of each object with the keys in sorted order.
187
+ Parse the input in streaming fashion, outputting arrays of path
188
+ and leaf values (scalars and empty arrays or empty objects).
189
+ For example, `"a"` becomes `[[],"a"]`, and `[[],"a",["b"]]`
190
+ becomes `[[0],[]]`, `[[1],"a"]`, and `[[2,0],"b"]`.
210
191
211
- * `--raw-output` / `-r`:
192
+ This is useful for processing very large inputs. Use this in
193
+ conjunction with filtering and the `reduce` and `foreach` syntax
194
+ to reduce large inputs incrementally.
212
195
213
- With this option, if the filter's result is a string then it
214
- will be written directly to standard output rather than being
215
- formatted as a JSON string with quotes. This can be useful for
216
- making jq filters talk to non-JSON-based systems.
196
+ * `--stream-errors`:
217
197
218
- * `--join-output` / `-j`:
198
+ Like `--stream`, but invalid JSON inputs yield array values
199
+ where the first element is the error and the second is a path.
200
+ For example, `["a",n]` produces `["Invalid literal at line 1,
201
+ column 7",[1]]`.
219
202
220
- Like `-r` but jq won't print a newline after each output.
203
+ Implies `--stream`. Invalid JSON inputs produce no error values
204
+ when `--stream` without `--stream-errors`.
221
205
222
- * `--nul-output` / `-0 `:
206
+ * `--seq `:
223
207
224
- Like `-r` but jq will print NUL instead of newline after each output.
225
- This can be useful when the values being output can contain newlines.
208
+ Use the `application/json-seq` MIME type scheme for separating
209
+ JSON texts in jq's input and output. This means that an ASCII
210
+ RS (record separator) character is printed before each value on
211
+ output and an ASCII LF (line feed) is printed after every
212
+ output. Input JSON texts that fail to parse are ignored (but
213
+ warned about), discarding all subsequent input until the next
214
+ RS. This mode also parses the output of jq without the `--seq`
215
+ option.
226
216
227
217
* `-f filename` / `--from-file filename`:
228
218
229
219
Read filter from the file rather than from a command line, like
230
220
awk's -f option. You can also use '#' to make comments.
231
221
232
- * `-Ldirectory` / `- L directory`:
222
+ * `-L directory`:
233
223
234
224
Prepend `directory` to the search list for modules. If this
235
225
option is used then no builtin search list is used. See the
236
226
section on modules below.
237
227
238
- * `-e` / `--exit-status`:
239
-
240
- Sets the exit status of jq to 0 if the last output value was
241
- neither `false` nor `null`, 1 if the last output value was
242
- either `false` or `null`, or 4 if no valid result was ever
243
- produced. Normally jq exits with 2 if there was any usage
244
- problem or system error, 3 if there was a jq program compile
245
- error, or 0 if the jq program ran.
246
-
247
- Another way to set the exit status is with the `halt_error`
248
- builtin function.
249
-
250
228
* `--arg name value`:
251
229
252
230
This option passes a value to the jq program as a predefined
@@ -297,6 +275,32 @@ sections:
297
275
Remaining arguments are positional JSON text arguments. These
298
276
are available to the jq program as `$ARGS.positional[]`.
299
277
278
+ * `--exit-status` / `-e`:
279
+
280
+ Sets the exit status of jq to 0 if the last output value was
281
+ neither `false` nor `null`, 1 if the last output value was
282
+ either `false` or `null`, or 4 if no valid result was ever
283
+ produced. Normally jq exits with 2 if there was any usage
284
+ problem or system error, 3 if there was a jq program compile
285
+ error, or 0 if the jq program ran.
286
+
287
+ Another way to set the exit status is with the `halt_error`
288
+ builtin function.
289
+
290
+ * `--binary` / `-b`:
291
+
292
+ Windows users using WSL, MSYS2, or Cygwin, should use this option
293
+ when using a native jq.exe, otherwise jq will turn newlines (LFs)
294
+ into carriage-return-then-newline (CRLF).
295
+
296
+ * `--version` / `-V`:
297
+
298
+ Output the jq version and exit with zero.
299
+
300
+ * `--help` / `-h`:
301
+
302
+ Output the jq help and exit with zero.
303
+
300
304
* `--`:
301
305
302
306
Terminates argument processing. Remaining arguments are
@@ -311,7 +315,7 @@ sections:
311
315
program lines followed by one input line, as many lines of
312
316
output as are expected (one per output), and a terminating empty
313
317
line. Compilation failure tests start with a line containing
314
- only " %%FAIL" , then a line containing the program to compile,
318
+ only ` %%FAIL` , then a line containing the program to compile,
315
319
then a line containing an error message to compare to the
316
320
actual.
317
321
0 commit comments