tar.jq

September 10, 2025 ยท View on GitHub

tar archive creator for jq.

Usage

The tar(g) functions takes filter g as argument that should output zero or more file objects with the required keys name and data. See source code for other optional keys.

# -n means don't read any input files
# -j raw string output any skip new lines
# -L . add current directory to library path so that include("tar") includes tar.jq
$ jq -nj -L . 'include "tar"; tar(
    {name: "hello.txt", data: "world\n"},
    {name: "test.json", data: ({hello: "world"} | tojson)}
)' | tar x
-rw-r--r--  0 user   group       5  1 Jan  1970 hello.txt
-rw-r--r--  0 user   group      17  1 Jan  1970 test.json
$ cat hello.txt
world
$ cat file.json
{"hello":"world"}

License

Copyright (c) 2025 Mattias Wadman

tar.jq is distributed under the terms of the MIT License.

See the LICENSE file for license details.