From 52d07c2b7b2b34b4e805e4e9fb12fe7355d36970 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
-f filename
/ --from-file filename
:Read filter from the file rather than from a command line, like - awk's -f option. You can also use '#' to make comments.
+ awk's -f option.-L directory
:jq has a library/module system. Modules are files whose names end @@ -8295,6 +8353,7 @@ by a semi-colon, where the first number is one of these:
"Plain assignment: =": "plain-assignment", "Complex assignments": "complex-assignments", "Assignment": "assignment", + "Comments": "comments", "import RelativePathString as NAME [\u003cmetadata\u003e];": "import-relativepathstring-as-name", "include RelativePathString [\u003cmetadata\u003e];": "include-relativepathstring", "import RelativePathString as $NAME [\u003cmetadata\u003e];": "import-relativepathstring-as-$name", -- cgit v1.2.3
Comments
+You can write comments in your jq filters using
+#
.A
+#
character (not part of a string) starts a comment. +All characters from#
to the end of the line are ignored.If the end of the line is preceded by an odd number of backslash +characters, the following line is also considered part of the +comment and is ignored.
+For example, the following code outputs
+ +[1,3,4,7]
Backslash continuing the comment on the next line can be useful +when writing the "shebang" for a jq script:
+ +The
+exec
line is considered a comment by jq, so it is ignored. +But it is not ignored bysh
, since insh
a backslash at the +end of the line does not continue the comment. +With this trick, when the script is invoked assum 1 2
, +/bin/sh -- /path/to/sum 1 2
will be run, andsh
will then +runexec jq --args -MRnf /path/to/sum -- 1 2
replacing itself +with ajq
interpreter invoked with the specified options (-M
, +-R
,-n
,--args
), that evaluates the current file ($0
), +with the arguments ($@
) that were passed tosh
.