Add --argfile variant of --arg (issue #117)
This is useful when one has a database (in JSON form) to query using jq
input data.
% echo '{"a":1, "c":5}' > db.json
% echo '"c"'|./jq --argfile f /tmp/a '$f[.]'
5
% echo '"a"'|./jq --argfile f /tmp/a '$f[.]'
1
% echo '"b"'|./jq --argfile f /tmp/a '$f[.]'
null
%
This commit is contained in:
1 parent
0535e724a2
commit
03598bb5d6
2 files changed
+46
-4
No files matched your search
@@ -127,6 +127,14 @@ sections:
|
||||
variable. If you run jq with `--arg foo bar`, then `$foo` is
|
||||
available in the program and has the value `"bar"`.
|
||||
|
||||
* `--argfile name filename`:
|
||||
|
||||
This option passes the first value from the named file as a
|
||||
value to the jq program as a predefined variable. If you run jq
|
||||
with `--argfile foo bar`, then `$foo` is available in the
|
||||
program and has the value resulting from parsing the content of
|
||||
the file named `bar`.
|
||||
|
||||
- title: Basic filters
|
||||
entries:
|
||||
- title: "`.`"
|
||||
|
||||
Reference in new issue
Block a user