neulab/tldr huggingface dataset:
--headless  Do not start a UI.  When supplied with --embed this implies that the embedding application does not intend to (immediately) start a UI.  Also useful for "scraping" messages in a pipe. :help --headless
--listen address Start RPC server on this pipe or TCP socket.
-h, --help  Print usage information and exit.
-v, --version Print version information and exit.
NVIM_LOG_FILE Low-level log file, usually found at ~/.cache/nvim/log.  :help $NVIM_LOG_FILE
VIM         Used to locate user files, such as init.vim.  System-dependent. :help $VIM
VIMRUNTIME  Used to locate runtime files (documentation, syntax highlighting, etc.).
XDG_CONFIG_HOME Path to the user-local configuration directory, see FILES. Defaults to ~/.config.  :help xdg
XDG_DATA_HOME Like XDG_CONFIG_HOME, but used to store data not generally edited by the user, namely swap, backup, and ShaDa files. Defaults to ~/.local/share.  :help xdg
VIMINIT     Ex commands to be executed at startup.  :help VIMINIT
SHELL       Used to initialize the 'shell' option, which decides the default shell used by features like :terminal, :!, and system().
~/.config/nvim/init.vim  User-local nvim configuration file.
~/.config/nvim           User-local nvim configuration directory.  See also XDG_CONFIG_HOME.
$VIM/sysinit.vim         System-global nvim configuration file.
$VIM                     System-global nvim runtime directory.
Nvim was started by Thiago de Arruda.  Most of Vim was written by Bram Moolenaar.  Vim is based on Stevie, worked on by Tim Thompson, Tony Andrews, and G.R. (Fred) Walter.  :help credits
KPARTX(8)                    System Manager's Manual                   KPARTX(8)
kpartx - Create device maps from partition tables.
kpartx [-a|-d|-u|-l] [-r] [-p] [-f] [-g] [-s|-n] [-v] wholedisk
This tool, derived from util-linux' partx, reads partition tables on specified device and create device maps over partitions segments detected. It is called from hotplug upon device maps creation and deletion.
-a     Add partition mappings.
-d     Delete partition mappings.
-u     Update partition mappings.
-l     List partition mappings that would be added -a.
-r     Read-only partition mappings.
-p     Set device name-partition number delimiter.
-f     Force creation of mappings; overrides 'no_partitions' feature.
-g     Force GUID partition table (GPT).
-s     Sync mode (Default). Don't return until the partitions are created.
-n     Nosync mode. Return before the partitions are created.
-v     Operate verbosely.
To mount all the partitions in a raw disk image:
kpartx -av disk.img
This will output lines such as:
add map loop1p1 (254:4): 0 409597 linear 7:1 3
The loop1p1 is the name of a device file under /dev/mapper which you can use to access the partition, for example to fsck it:
fsck /dev/mapper/loop1p1
When you're done, you need to remove the devices:
kpartx -d disk.img
multipath(8) multipathd(8) hotplug(8)
This man page was assembled By Patrick Caulfield for the Debian project.
multipath-tools was developed by Christophe Varoqui <christophe.varoqui@opensvc.com> and others.
scrcpy(1)                    General Commands Manual                   scrcpy(1)
scrcpy - Display and control your Android device
scrcpy [options]
scrcpy provides display and control of Android devices connected on USB (or over TCP/IP). It does not require any root access.
--always-on-top Make scrcpy window always on top (above other windows).
-b, --bit-rate value Encode the video at the given bit-rate, expressed in bits/s. Unit suffixes are supported: 'K' (x1000) and 'M' (x1000000).
Default is 8000000.
--codec-options key[:type]=value[,...] Set a list of comma-separated key:type=value options for the device encoder.
The possible values for 'type' are 'int' (default), 'long', 'float' and 'string'.
The list of possible codec options is available in the Android documentation ⟨https://d.android.com/reference/android/media/MediaFormat⟩.
--crop width:height:x:y Crop the device screen on the server.
The values are expressed in the device natural orientation (typically, portrait for a phone, landscape for a tablet). Any --max-size value is computed on the cropped size.
--disable-screensaver Disable screensaver while scrcpy is running.
--display id Specify the display id to mirror.
The list of possible display ids can be listed by "adb shell dumpsys display" (search "mDisplayId=" in the output).
Default is 0.
--display-buffer ms Add a buffering delay (in milliseconds) before displaying. This increases latency to compensate for jitter.
Default is 0 (no buffering).
--encoder name Use a specific MediaCodec encoder (must be a H.264 encoder).
--force-adb-forward Do not attempt to use "adb reverse" to connect to the device.
--forward-all-clicks By default, right-click triggers BACK (or POWER on) and middle- click triggers HOME. This option disables these shortcuts and forward the clicks to the device instead.
-f, --fullscreen Start in fullscreen.
-K, --hid-keyboard Simulate a physical keyboard by using HID over AOAv2.
This provides a better experience for IME users, and allows to generate non-ASCII characters, contrary to the default injection method.
It may only work over USB, and is currently only supported on Linux.
The keyboard layout must be configured (once and for all) on the device, via Settings -> System -> Languages and input -> Physical keyboard. This settings page can be started directly:
adb shell am start -a android.settings.HARD_KEYBOARD_SETTINGS
However, the option is only available when the HID keyboard is enabled (or a physical keyboard is connected).
--legacy-paste Inject computer clipboard text as a sequence of key events on Ctrl+v (like MOD+Shift+v).
This is a workaround for some devices not behaving as expected when setting the device clipboard programmatically.
--lock-video-orientation[=value] Lock video orientation to value. Possible values are "unlocked", "initial" (locked to the initial orientation), 0, 1, 2 and 3. Natural device orientation is 0, and each increment adds a 90 degrees rotation counterclockwise.
Default is "unlocked".
Passing the option without argument is equivalent to passing "initial".
--max-fps value Limit the framerate of screen capture (officially supported since Android 10, but may work on earlier versions).
-m, --max-size value Limit both the width and height of the video to value. The other dimension is computed so that the device aspect-ratio is preserved.
Default is 0 (unlimited).
--no-clipboard-autosync By default, scrcpy automatically synchronizes the computer clipboard to the device clipboard before injecting Ctrl+v, and the device clipboard to the computer clipboard whenever it changes.
This option disables this automatic synchronization.
-n, --no-control Disable device control (mirror the device in read-only).
-N, --no-display Do not display device (only when screen recording is enabled).
--no-key-repeat Do not forward repeated key events when a key is held down.
--no-mipmaps If the renderer is OpenGL 3.0+ or OpenGL ES 2.0+, then mipmaps are automatically generated to improve downscaling quality. This option disables the generation of mipmaps.
-p, --port port[:port] Set the TCP port (range) used by the client to listen.
Default is 27183:27199.
--power-off-on-close Turn the device screen off when closing scrcpy.
--prefer-text Inject alpha characters and space as text events instead of key events.
This avoids issues when combining multiple keys to enter special characters, but breaks the expected behavior of alpha keys in games (typically WASD).
--push-target path Set the target directory for pushing files to the device by drag & drop. It is passed as-is to "adb push".
Default is "/sdcard/Download/".
--raw-key-events Inject key events for all input keys, and ignore text events.
-r, --record file Record screen to file.
The format is determined by the --record-format option if set, or by the file extension (.mp4 or .mkv).
--record-format format Force recording format (either mp4 or mkv).
--render-driver name Request SDL to use the given render driver (this is just a hint).
Supported names are currently "direct3d", "opengl", "opengles2", "opengles", "metal" and "software".
⟨https://wiki.libsdl.org/SDL_HINT_RENDER_DRIVER⟩
--rotation value Set the initial display rotation. Possibles values are 0, 1, 2 and 3. Each increment adds a 90 degrees rotation counterclockwise.
-s, --serial number The device serial number. Mandatory only if several devices are connected to adb.
--shortcut-mod key[+...]][,...] Specify the modifiers to use for scrcpy shortcuts. Possible keys are "lctrl", "rctrl", "lalt", "ralt", "lsuper" and "rsuper".
A shortcut can consist in several keys, separated by '+'. Several shortcuts can be specified, separated by ','.
For example, to use either LCtrl+LAlt or LSuper for scrcpy shortcuts, pass "lctrl+lalt,lsuper".
Default is "lalt,lsuper" (left-Alt or left-Super).
--tcpip[=ip[:port]] Configure and reconnect the device over TCP/IP.
If a destination address is provided, then scrcpy connects to this address before starting. The device must listen on the given TCP port (default is 5555).
If no destination address is provided, then scrcpy attempts to find the IP address of the current device (typically connected over USB), enables TCP/IP mode, then connects to this address before starting.
-S, --turn-screen-off Turn the device screen off immediately.
-t, --show-touches Enable "show touches" on start, restore the initial value on exit.
It only shows physical touches (not clicks from scrcpy).
--tunnel-host ip Set the IP address of the adb tunnel to reach the scrcpy server. This option automatically enables --force-adb-forward.
Default is localhost.
--tunnel-port port Set the TCP port of the adb tunnel to reach the scrcpy server. This option automatically enables --force-adb-forward.
Default is 0 (not forced): the local port used for establishing the tunnel will be used.
--v4l2-sink /dev/videoN Output to v4l2loopback device.
It requires to lock the video orientation (see --lock-video-orientation).
--v4l2-buffer ms Add a buffering delay (in milliseconds) before pushing frames. This increases latency to compensate for jitter.
This option is similar to --display-buffer, but specific to V4L2 sink.
-V, --verbosity value Set the log level ("verbose", "debug", "info", "warn" or "error").
Default is "info" for release builds, "debug" for debug builds.
-v, --version Print the version of scrcpy.
-w, --stay-awake Keep the device on while scrcpy is running, when the device is plugged in.
--window-borderless Disable window decorations (display borderless window).
--window-title text Set a custom window title.
--window-x value Set the initial window horizontal position.
Default is "auto".
--window-y value Set the initial window vertical position.
--window-width value Set the initial window width.
Default is 0 (automatic).
--window-height value Set the initial window height.
In the following list, MOD is the shortcut modifier. By default, it's (left) Alt or (left) Super, but it can be configured by --shortcut-mod (see above).
MOD+f  Switch fullscreen mode
MOD+Left Rotate display left
MOD+Right Rotate display right
MOD+g  Resize window to 1:1 (pixel-perfect)
MOD+w, Double-click on black borders Resize window to remove black borders
MOD+h, Home, Middle-click Click on HOME
MOD+b, MOD+Backspace, Right-click (when screen is on) Click on BACK
MOD+s  Click on APP_SWITCH
MOD+m  Click on MENU
MOD+Up Click on VOLUME_UP
MOD+Down Click on VOLUME_DOWN
MOD+p  Click on POWER (turn screen on/off)
Right-click (when screen is off) Turn screen on
MOD+o  Turn device screen off (keep mirroring)
MOD+Shift+o Turn device screen on
MOD+r  Rotate device screen
MOD+n  Expand notification panel
MOD+Shift+n Collapse notification panel
Mod+c  Copy to clipboard (inject COPY keycode, Android >= 7 only)
Mod+x  Cut to clipboard (inject CUT keycode, Android >= 7 only)
MOD+v  Copy computer clipboard to device, then paste (inject PASTE keycode, Android >= 7 only)
MOD+Shift+v Inject computer clipboard text as a sequence of key events
MOD+i  Enable/disable FPS counter (print frames/second in logs)
Ctrl+click-and-move Pinch-to-zoom from the center of the screen
Drag & drop APK file Install APK from computer
Drag & drop non-APK file Push file to device (see --push-target)
Environment variables ADB    Specify the path to adb.
SCRCPY_SERVER_PATH Specify the path to server binary.
scrcpy is written by Romain Vimont.
This manual page was written by Yangfl ⟨mmyangfl@gmail.com⟩ for the Debian Project (and may be used by others).
Report bugs to ⟨https://github.com/Genymobile/scrcpy/issues⟩.
Copyright © 2018 Genymobile Genymobile ⟨https://www.genymobile.com⟩
Copyright © 2018-2020 Romain Vimont ⟨rom@rom1v.com⟩
Licensed under the Apache License, Version 2.0.
⟨https://github.com/Genymobile/scrcpy⟩
FC-MATCH(1)                                                          FC-MATCH(1)
fc-match - match available fonts
fc-match [ -asvVh ] [ --all ] [ --sort ] [ --verbose ] [ -f format | --format format ] [ --version ] [ --help ] [ pattern  [ element ... ]  ]
fc-match matches pattern (empty pattern by default) using the normal fontconfig matching rules to find the best font available.  If --sort is given, the sorted list of best matching fonts is displayed.  The --all option works like --sort except that no pruning is done on the list of fonts.
If any elements are specified, only those are printed.  Otherwise short file name, family, and style are printed, unless verbose output is requested.
-a --all Displays sorted list of best matching fonts, but do not do any pruning on the list.
-s --sort Displays sorted list of best matching fonts.
-v --verbose Print verbose output of the whole font pattern for each match, or elements if any is provided.
-f --format format Format output according to the format specifier format.
pattern Displays fonts matching pattern (uses empty pattern by default).
element If set, the element property is displayed for matching fonts.
fc-match sans Display the best matching font categorized into sans-serif generic family, filtered by current locale
fc-match sans:lang=en Display the best matching font categorized into sans-serif generic family, filtered by English language
fc-match sans:lang=en:weight=bold Display the best matching font categorized into sans-serif generic family, filtered by English language and weight is bold.
fc-list(1) FcFontMatch(3) FcFontSort(3) FcPatternFormat(3) fc-cat(1) fc- cache(1) fc-pattern(1) fc-query(1) fc-scan(1)
This manual page was updated by Patrick Lam <plam@csail.mit.edu>.
HCITOOL(1)                 Linux System Administration                HCITOOL(1)
hcitool - configure Bluetooth connections
hcitool [-h] hcitool [-i <hciX>] [command [command parameters]]
hcitool is used to configure Bluetooth connections and send some special command to Bluetooth devices. If no command is given, or if the option -h is used, hcitool prints some usage information and exits.
-h     Gives a list of possible commands
-i <hciX> The command is applied to device hciX , which must be the name of an installed Bluetooth device. If not specified, the command will be sent to the first available Bluetooth device.
dev    Display local devices
inq    Inquire remote devices. For each discovered device, Bluetooth device address, clock offset and class are printed.
scan   Inquire remote devices. For each discovered device, device name are printed.
name <bdaddr> Print device name of remote device with Bluetooth address bdaddr.
info <bdaddr> Print device name, version and supported features of remote device with Bluetooth address bdaddr.
spinq  Start periodic inquiry process. No inquiry results are printed.
epinq  Exit periodic inquiry process.
cmd <ogf> <ocf> [parameters] Submit an arbitrary HCI command to local device.  ogf, ocf and parameters are hexadecimal bytes.
con    Display active baseband connections
cc [--role=m|s] [--pkt-type=<ptype>] <bdaddr> Create baseband connection to remote device with Bluetooth address bdaddr.  Option --pkt-type specifies a list of allowed packet types.  <ptype> is a comma-separated list of packet types, where the possible packet types are DM1, DM3, DM5, DH1, DH3, DH5, HV1, HV2, HV3.  Default is to allow all packet types. Option --role can have value m (do not allow role switch, stay master) or s (allow role switch, become slave if the peer asks to become master). Default is m.
dc <bdaddr> [reason] Delete baseband connection from remote device with Bluetooth address bdaddr.  The reason can be one of the Bluetooth HCI error codes. Default is 19 for user ended connections. The value must be given in decimal.
sr <bdaddr> <role> Switch role for the baseband connection from the remote device to master or slave.
cpt <bdaddr> <packet types> Change packet types for baseband connection to device with Bluetooth address bdaddr.  packet types is a comma-separated list of packet types, where the possible packet types are DM1, DM3, DM5, DH1, DH3, DH5, HV1, HV2, HV3.
rssi <bdaddr> Display received signal strength information for the connection to the device with Bluetooth address bdaddr.
lq <bdaddr> Display link quality for the connection to the device with Bluetooth address bdaddr.
tpl <bdaddr> [type] Display transmit power level for the connection to the device with Bluetooth address bdaddr.  The type can be 0 for the current transmit power level (which is default) or 1 for the maximum transmit power level.
afh <bdaddr> Display AFH channel map for the connection to the device with Bluetooth address bdaddr.
lp <bdaddr> [value] With no value, displays link policy settings for the connection to the device with Bluetooth address bdaddr.  If value is given, sets the link policy settings for that connection to value.  Possible values are RSWITCH, HOLD, SNIFF and PARK.
lst <bdaddr> [value] With no value, displays link supervision timeout for the connection to the device with Bluetooth address bdaddr.  If value is given, sets the link supervision timeout for that connection to value slots, or to infinite if value is 0.
auth <bdaddr> Request authentication for the device with Bluetooth address bdaddr.
enc <bdaddr> [encrypt enable] Enable or disable the encryption for the device with Bluetooth address bdaddr.
key <bdaddr> Change the connection link key for the device with Bluetooth address bdaddr.
clkoff <bdaddr> Read the clock offset for the device with Bluetooth address bdaddr.
clock [bdaddr] [which clock] Read the clock for the device with Bluetooth address bdaddr.  The clock can be 0 for the local clock or 1 for the piconet clock (which is default).
lescan [--privacy] [--passive] [--whitelist] [--discovery=g|l] [--duplicates] Start LE scan
leinfo [--static] [--random] <bdaddr> Get LE remote information
lewladd [--random] <bdaddr> Add device to LE White List
lewlrm <bdaddr> Remove device from LE White List
lewlsz Read size of LE White List
lewlclr Clear LE White List
lerladd [--local irk] [--peer irk] [--random] <bdaddr> Add device to LE Resolving List
lerlrm <bdaddr> Remove device from LE Resolving List
lerlclr Clear LE Resolving List
lerlsz Read size of LE Resolving List
lerlon Enable LE Address Resolution
lerloff Disable LE Address Resolution
lecc [--static] [--random] <bdaddr> | [--whitelist] Create a LE Connection
ledc <handle> [reason] Disconnect a LE Connection
lecup <handle> <min> <max> <latency> <timeout> LE Connection Update
Written by Maxim Krasnyansky <maxk@qualcomm.com> and Marcel Holtmann <marcel@holtmann.org>
man page by Fabrizio Gennari <fabrizio.gennari@philips.com>
gh-secret-set - Create or update secrets
gh secret set <secret-name> [flags]
Set a value for a secret on one of the following levels: - repository (default): available to Actions runs in a repository - environment: available to Actions runs for a deployment environment in a repository - organization: available to Actions runs within an organization - user: available to Codespaces for your user
Organization and user secrets can optionally be restricted to only be available to specific repositories.
Secret values are locally encrypted before being sent to GitHub.
-b, --body=""      The value for the secret (reads from standard input if not specified)
-e, --env=""      Set deployment environment secret
--no-store[=false]      Print the encrypted, base64-encoded value instead of storing it on Github
-o, --org=""      Set organization secret
-r, --repos=[]      List of repositories that can access an organization or user secret
-u, --user[=false]      Set a secret for your user
-v, --visibility="private"      Set visibility for an organization secret: {all|private|selected}
# Paste secret value for the current repository in an interactive prompt $ gh secret set MYSECRET
# Read secret value from an environment variable $ gh secret set MYSECRET --body "$ENV_VALUE"
# Read secret value from a file $ gh secret set MYSECRET < myfile.txt
# Set secret for a deployment environment in the current repository $ gh secret set MYSECRET --env myenvironment
# Set organization-level secret visible to both public and private repositories $ gh secret set MYSECRET --org myOrg --visibility all
# Set organization-level secret visible to specific repositories $ gh secret set MYSECRET --org myOrg --repos repo1,repo2,repo3
# Set user-level secret for Codespaces $ gh secret set MYSECRET --user
gh-secret(1)
JQ(1)                                                                      JQ(1)
jq - Command-line JSON processor
jq [options...] filter [files...]
jq can transform JSON in various ways, by selecting, iterating, reducing and otherwise mangling JSON documents. For instance, running the command jq ´map(.price) | add´ will take an array of JSON objects as input and return the sum of their "price" fields.
jq can accept text input as well, but by default, jq reads a stream of JSON entities (including numbers and other literals) from stdin. Whitespace is only needed to separate entities such as 1 and 2, and true and false. One or more files may be specified, in which case jq will read input from those instead.
The options are described in the INVOKING JQ section; they mostly concern input and output formatting. The filter is written in the jq language and specifies how to transform the input file or document.
A jq program is a "filter": it takes an input, and produces an output. There are a lot of builtin filters for extracting a particular field of an object, or converting a number to a string, or various other standard tasks.
Filters can be combined in various ways - you can pipe the output of one filter into another filter, or collect the output of a filter into an array.
Some filters produce multiple results, for instance there´s one that produces all the elements of its input array. Piping that filter into a second runs the second filter for each element of the array. Generally, things that would be done with loops and iteration in other languages are just done by gluing filters together in jq.
It´s important to remember that every filter has an input and an output. Even literals like "hello" or 42 are filters - they take an input but always produce the same literal as output. Operations that combine two filters, like addition, generally feed the same input to both and combine the results. So, you can implement an averaging filter as add / length - feeding the input array both to the add filter and the length filter and then performing the division.
But that´s getting ahead of ourselves. :) Let´s start with something simpler:
jq filters run on a stream of JSON data. The input to jq is parsed as a sequence of whitespace-separated JSON values which are passed through the provided filter one at a time. The output(s) of the filter are written to standard out, again as a sequence of whitespace-separated JSON data.
Note: it is important to mind the shell´s quoting rules. As a general rule it´s best to always quote (with single-quote characters) the jq program, as too many characters with special meaning to jq are also shell meta-characters. For example, jq "foo" will fail on most Unix shells because that will be the same as jq foo, which will generally fail because foo is not defined. When using the Windows command shell (cmd.exe) it´s best to use double quotes around your jq program when given on the command-line (instead of the -f program-file option), but then double-quotes in the jq program need backslash escaping.
You can affect how jq reads and writes its input and output using some command-line options:
•   --version:
Output the jq version and exit with zero.
•   --seq:
Use the application/json-seq MIME type scheme for separating JSON texts in jq´s input and output. This means that an ASCII RS (record separator) character is printed before each value on output and an ASCII LF (line feed) is printed after every output. Input JSON texts that fail to parse are ignored (but warned about), discarding all subsequent input until the next RS. This mode also parses the output of jq without the --seq option.
•   --stream:
Parse the input in streaming fashion, outputing arrays of path and leaf values (scalars and empty arrays or empty objects). For example, "a" becomes [[],"a"], and [[],"a",["b"]] becomes [[0],[]], [[1],"a"], and [[1,0],"b"].
This is useful for processing very large inputs. Use this in conjunction with filtering and the reduce and foreach syntax to reduce large inputs incrementally.
•   --slurp/-s:
Instead of running the filter for each JSON object in the input, read the entire input stream into a large array and run the filter just once.
•   --raw-input/-R:
Don´t parse the input as JSON. Instead, each line of text is passed to the filter as a string. If combined with --slurp, then the entire input is passed to the filter as a single long string.
•   --null-input/-n:
Don´t read any input at all! Instead, the filter is run once using null as the input. This is useful when using jq as a simple calculator or to construct JSON data from scratch.
•   --compact-output / -c:
By default, jq pretty-prints JSON output. Using this option will result in more compact output by instead putting each JSON object on a single line.
•   --tab:
Use a tab for each indentation level instead of two spaces.
•   --indent n:
Use the given number of spaces (no more than 8) for indentation.
•   --color-output / -C and --monochrome-output / -M:
By default, jq outputs colored JSON if writing to a terminal. You can force it to produce color even if writing to a pipe or a file using -C, and disable color with -M.
Colors can be configured with the JQ_COLORS environment variable (see below).
•   --ascii-output / -a:
jq usually outputs non-ASCII Unicode codepoints as UTF-8, even if the input specified them as escape sequences (like "\u03bc"). Using this option, you can force jq to produce pure ASCII output with every non-ASCII character replaced with the equivalent escape sequence.
•   --unbuffered
Flush the output after each JSON object is printed (useful if you´re piping a slow data source into jq and piping jq´s output elsewhere).
•   --sort-keys / -S:
Output the fields of each object with the keys in sorted order.
•   --raw-output / -r:
With this option, if the filter´s result is a string then it will be written directly to standard output rather than being formatted as a JSON string with quotes. This can be useful for making jq filters talk to non-JSON-based systems.
•   --join-output / -j:
Like -r but jq won´t print a newline after each output.
•   -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.
•   -Ldirectory / -L directory:
Prepend directory to the search list for modules. If this option is used then no builtin search list is used. See the section on modules below.
•   -e / --exit-status:
Sets the exit status of jq to 0 if the last output values was neither false nor null, 1 if the last output value was either false or null, or 4 if no valid result was ever produced. Normally jq exits with 2 if there was any usage problem or system error, 3 if there was a jq program compile error, or 0 if the jq program ran.
Another way to set the exit status is with the halt_error builtin function.
•   --arg name value:
This option passes a value to the jq program as a predefined variable. If you run jq with --arg foo bar, then $foo is available in the program and has the value "bar". Note that value will be treated as a string, so --arg foo 123 will bind $foo to "123".
Named arguments are also available to the jq program as $ARGS.named.
•   --argjson name JSON-text:
This option passes a JSON-encoded value to the jq program as a predefined variable. If you run jq with --argjson foo 123, then $foo is available in the program and has the value 123.
•   --slurpfile variable-name filename:
This option reads all the JSON texts in the named file and binds an array of the parsed JSON values to the given global variable. If you run jq with --argfile foo bar, then $foo is available in the program and has an array whose elements correspond to the texts in the file named bar.
•   --argfile variable-name filename:
Do not use. Use --slurpfile instead.
(This option is like --slurpfile, but when the file has just one text, then that is used, else an array of texts is used as in --slurpfile.)
•   --args:
Remaining arguments are positional string arguments. These are available to the jq program as $ARGS.positional[].
•   --jsonargs:
Remaining arguments are positional JSON text arguments. These are available to the jq program as $ARGS.positional[].
•   --run-tests [filename]:
Runs the tests in the given file or standard input. This must be the last option given and does not honor all preceding options. The input consists of comment lines, empty lines, and program lines followed by one input line, as many lines of output as are expected (one per output), and a terminating empty line. Compilation failure tests start with a line containing only "%%FAIL", then a line containing the program to compile, then a line containing an error message to compare to the actual.
Be warned that this option can change backwards-incompatibly.
Identity: . The absolute simplest filter is . . This is a filter that takes its input and produces it unchanged as output. That is, this is the identity operator.
Since jq by default pretty-prints all output, this trivial program can be a useful way of formatting JSON output from, say, curl.
jq ´.´ "Hello, world!" => "Hello, world!"
Object Identifier-Index: .foo, .foo.bar The simplest useful filter is .foo. When given a JSON object (aka dictionary or hash) as input, it produces the value at the key "foo", or null if there´s none present.
A filter of the form .foo.bar is equivalent to .foo|.bar.
This syntax only works for simple, identifier-like keys, that is, keys that are all made of alphanumeric characters and underscore, and which do not start with a digit.
If the key contains special characters, you need to surround it with double quotes like this: ."foo$", or else .["foo$"].
For example .["foo::bar"] and .["foo.bar"] work while .foo::bar does not, and .foo.bar means .["foo"].["bar"].
jq ´.foo´ {"foo": 42, "bar": "less interesting data"} => 42
jq ´.foo´ {"notfoo": true, "alsonotfoo": false} => null
jq ´.["foo"]´ {"foo": 42} => 42
Optional Object Identifier-Index: .foo? Just like .foo, but does not output even an error when . is not an array or an object.
jq ´.foo?´ {"foo": 42, "bar": "less interesting data"} => 42
jq ´.foo?´ {"notfoo": true, "alsonotfoo": false} => null
jq ´.["foo"]?´ {"foo": 42} => 42
jq ´[.foo?]´ [1,2] => []
Generic Object Index: .[<string>] You can also look up fields of an object using syntax like .["foo"] (.foo above is a shorthand version of this, but only for identifier-like strings).
Array Index: .[2] When the index value is an integer, .[<value>] can index arrays. Arrays are zero-based, so .[2] returns the third element.
Negative indices are allowed, with -1 referring to the last element, -2 referring to the next to last element, and so on.
jq ´.[0]´ [{"name":"JSON", "good":true}, {"name":"XML", "good":false}] => {"name":"JSON", "good":true}
jq ´.[2]´ [{"name":"JSON", "good":true}, {"name":"XML", "good":false}] => null
jq ´.[-2]´ [1,2,3] => 2
Array/String Slice: .[10:15] The .[10:15] syntax can be used to return a subarray of an array or substring of a string. The array returned by .[10:15] will be of length 5, containing the elements from index 10 (inclusive) to index 15 (exclusive). Either index may be negative (in which case it counts backwards from the end of the array), or omitted (in which case it refers to the start or end of the array).
jq ´.[2:4]´ ["a","b","c","d","e"] => ["c", "d"]
jq ´.[2:4]´ "abcdefghi" => "cd"
jq ´.[:3]´ ["a","b","c","d","e"] => ["a", "b", "c"]
jq ´.[-2:]´ ["a","b","c","d","e"] => ["d", "e"]
Array/Object Value Iterator: .[] If you use the .[index] syntax, but omit the index entirely, it will return all of the elements of an array. Running .[] with the input [1,2,3] will produce the numbers as three separate results, rather than as a single array.
You can also use this on an object, and it will return all the values of the object.
jq ´.[]´ [{"name":"JSON", "good":true}, {"name":"XML", "good":false}] => {"name":"JSON", "good":true}, {"name":"XML", "good":false}
jq ´.[]´ [] =>
jq ´.[]´ {"a": 1, "b": 1} => 1, 1
.[]? Like .[], but no errors will be output if . is not an array or object.
Comma: , If two filters are separated by a comma, then the same input will be fed into both and the two filters´ output value streams will be concatenated in order: first, all of the outputs produced by the left expression, and then all of the outputs produced by the right. For instance, filter .foo, .bar, produces both the "foo" fields and "bar" fields as separate outputs.
jq ´.foo, .bar´ {"foo": 42, "bar": "something else", "baz": true} => 42, "something else"
jq ´.user, .projects[]´ {"user":"stedolan", "projects": ["jq", "wikiflow"]} => "stedolan", "jq", "wikiflow"
jq ´.[4,2]´ ["a","b","c","d","e"] => "e", "c"
Pipe: | The | operator combines two filters by feeding the output(s) of the one on the left into the input of the one on the right. It´s pretty much the same as the Unix shell´s pipe, if you´re used to that.
If the one on the left produces multiple results, the one on the right will be run for each of those results. So, the expression .[] | .foo retrieves the "foo" field of each element of the input array.
Note that .a.b.c is the same as .a | .b | .c.
Note too that . is the input value at the particular stage in a "pipeline", specifically: where the . expression appears. Thus .a | . | .b is the same as .a.b, as the . in the middle refers to whatever value .a produced.
jq ´.[] | .name´ [{"name":"JSON", "good":true}, {"name":"XML", "good":false}] => "JSON", "XML"
Parenthesis Parenthesis work as a grouping operator just as in any typical programming language.
jq ´(. + 2) * 5´ 1 => 15
jq supports the same set of datatypes as JSON - numbers, strings, booleans, arrays, objects (which in JSON-speak are hashes with only string keys), and "null".
Booleans, null, strings and numbers are written the same way as in javascript. Just like everything else in jq, these simple values take an input and produce an output - 42 is a valid jq expression that takes an input, ignores it, and returns 42 instead.
Array construction: [] As in JSON, [] is used to construct arrays, as in [1,2,3]. The elements of the arrays can be any jq expression, including a pipeline. All of the results produced by all of the expressions are collected into one big array. You can use it to construct an array out of a known quantity of values (as in [.foo, .bar, .baz]) or to "collect" all the results of a filter into an array (as in [.items[].name])
Once you understand the "," operator, you can look at jq´s array syntax in a different light: the expression [1,2,3] is not using a built-in syntax for comma-separated arrays, but is instead applying the [] operator (collect results) to the expression 1,2,3 (which produces three different results).
If you have a filter X that produces four results, then the expression [X] will produce a single result, an array of four elements.
jq ´[.user, .projects[]]´ {"user":"stedolan", "projects": ["jq", "wikiflow"]} => ["stedolan", "jq", "wikiflow"]
jq ´[ .[] | . * 2]´ [1, 2, 3] => [2, 4, 6]
Object Construction: {} Like JSON, {} is for constructing objects (aka dictionaries or hashes), as in: {"a": 42, "b": 17}.
If the keys are "identifier-like", then the quotes can be left off, as in {a:42, b:17}. Keys generated by expressions need to be parenthesized, e.g., {("a"+"b"):59}.
The value can be any expression (although you may need to wrap it in parentheses if it´s a complicated one), which gets applied to the {} expression´s input (remember, all filters have an input and an output).
{foo: .bar}
will produce the JSON object {"foo": 42} if given the JSON object {"bar":42, "baz":43} as its input. You can use this to select particular fields of an object: if the input is an object with "user", "title", "id", and "content" fields and you just want "user" and "title", you can write
{user: .user, title: .title}
Because that is so common, there´s a shortcut syntax for it: {user, title}.
If one of the expressions produces multiple results, multiple dictionaries will be produced. If the input´s
{"user":"stedolan","titles":["JQ Primer", "More JQ"]}
then the expression
{user, title: .titles[]}
will produce two outputs:
{"user":"stedolan", "title": "JQ Primer"} {"user":"stedolan", "title": "More JQ"}
Putting parentheses around the key means it will be evaluated as an expression. With the same input as above,
{(.user): .titles}
{"stedolan": ["JQ Primer", "More JQ"]}
jq ´{user, title: .titles[]}´ {"user":"stedolan","titles":["JQ Primer", "More JQ"]} => {"user":"stedolan", "title": "JQ Primer"}, {"user":"stedolan", "title": "More JQ"}
jq ´{(.user): .titles}´ {"user":"stedolan","titles":["JQ Primer", "More JQ"]} => {"stedolan": ["JQ Primer", "More JQ"]}
Recursive Descent: .. Recursively descends ., producing every value. This is the same as the zero-argument recurse builtin (see below). This is intended to resemble the XPath // operator. Note that ..a does not work; use ..|.a instead. In the example below we use ..|.a? to find all the values of object keys "a" in any object found "below" ..
This is particularly useful in conjunction with path(EXP) (also see below) and the ? operator.
jq ´..|.a?´ [[{"a":1}]] => 1
Some jq operator (for instance, +) do different things depending on the type of their arguments (arrays, numbers, etc.). However, jq never does implicit type conversions. If you try to add a string to an object you´ll get an error message and no result.
Addition: + The operator + takes two filters, applies them both to the same input, and adds the results together. What "adding" means depends on the types involved:
•   Numbers are added by normal arithmetic.
•   Arrays are added by being concatenated into a larger array.
•   Strings are added by being joined into a larger string.
•   Objects are added by merging, that is, inserting all the key-value pairs from both objects into a single combined object. If both objects contain a value for the same key, the object on the right of the + wins. (For recursive merge use the * operator.)
null can be added to any value, and returns the other value unchanged.
jq ´.a + 1´ {"a": 7} => 8
jq ´.a + .b´ {"a": [1,2], "b": [3,4]} => [1,2,3,4]
jq ´.a + null´ {"a": 1} => 1
jq ´.a + 1´ {} => 1
jq ´{a: 1} + {b: 2} + {c: 3} + {a: 42}´ null => {"a": 42, "b": 2, "c": 3}
Subtraction: - As well as normal arithmetic subtraction on numbers, the - operator can be used on arrays to remove all occurrences of the second array´s elements from the first array.
jq ´4 - .a´ {"a":3} => 1
jq ´. - ["xml", "yaml"]´ ["xml", "yaml", "json"] => ["json"]
Multiplication, division, modulo: *, /, and % These infix operators behave as expected when given two numbers. Division by zero raises an error. x % y computes x modulo y.
Multiplying a string by a number produces the concatenation of that string that many times. "x" * 0 produces null.
Dividing a string by another splits the first using the second as separators.
Multiplying two objects will merge them recursively: this works like addition but if both objects contain a value for the same key, and the values are objects, the two are merged with the same strategy.
jq ´10 / . * 3´ 5 => 6
jq ´. / ", "´ "a, b,c,d, e" => ["a","b,c,d","e"]
jq ´{"k": {"a": 1, "b": 2}} * {"k": {"a": 0,"c": 3}}´ null => {"k": {"a": 0, "b": 2, "c": 3}}
jq ´.[] | (1 / .)?´ [1,0,-1] => 1, -1
length The builtin function length gets the length of various different types of value:
•   The length of a string is the number of Unicode codepoints it contains (which will be the same as its JSON-encoded length in bytes if it´s pure ASCII).
•   The length of an array is the number of elements.
•   The length of an object is the number of key-value pairs.
•   The length of null is zero.
jq ´.[] | length´ [[1,2], "string", {"a":2}, null] => 2, 6, 1, 0
utf8bytelength The builtin function utf8bytelength outputs the number of bytes used to encode a string in UTF-8.
jq ´utf8bytelength´ "\u03bc" => 2
keys, keys_unsorted The builtin function keys, when given an object, returns its keys in an array.
The keys are sorted "alphabetically", by unicode codepoint order. This is not an order that makes particular sense in any particular language, but you can count on it being the same for any two objects with the same set of keys, regardless of locale settings.
When keys is given an array, it returns the valid indices for that array: the integers from 0 to length-1.
The keys_unsorted function is just like keys, but if the input is an object then the keys will not be sorted, instead the keys will roughly be in insertion order.
jq ´keys´ {"abc": 1, "abcd": 2, "Foo": 3} => ["Foo", "abc", "abcd"]
jq ´keys´ [42,3,35] => [0,1,2]
has(key) The builtin function has returns whether the input object has the given key, or the input array has an element at the given index.
has($key) has the same effect as checking whether $key is a member of the array returned by keys, although has will be faster.
jq ´map(has("foo"))´ [{"foo": 42}, {}] => [true, false]
jq ´map(has(2))´ [[0,1], ["a","b","c"]] => [false, true]
in The builtin function in returns whether or not the input key is in the given object, or the input index corresponds to an element in the given array. It is, essentially, an inversed version of has.
jq ´.[] | in({"foo": 42})´ ["foo", "bar"] => true, false
jq ´map(in([0,1]))´ [2, 0] => [false, true]
map(x), map_values(x) For any filter x, map(x) will run that filter for each element of the input array, and return the outputs in a new array. map(.+1) will increment each element of an array of numbers.
Similarly, map_values(x) will run that filter for each element, but it will return an object when an object is passed.
map(x) is equivalent to [.[] | x]. In fact, this is how it´s defined. Similarly, map_values(x) is defined as .[] |= x.
jq ´map(.+1)´ [1,2,3] => [2,3,4]
jq ´map_values(.+1)´ {"a": 1, "b": 2, "c": 3} => {"a": 2, "b": 3, "c": 4}
path(path_expression) Outputs array representations of the given path expression in .. The outputs are arrays of strings (object keys) and/or numbers (array indices).
Path expressions are jq expressions like .a, but also .[]. There are two types of path expressions: ones that can match exactly, and ones that cannot. For example, .a.b.c is an exact match path expression, while .a[].b is not.
path(exact_path_expression) will produce the array representation of the path expression even if it does not exist in ., if . is null or an array or an object.
path(pattern) will produce array representations of the paths matching pattern if the paths exist in ..
Note that the path expressions are not different from normal expressions. The expression path(..|select(type=="boolean")) outputs all the paths to boolean values in ., and only those paths.
jq ´path(.a[0].b)´ null => ["a",0,"b"]
jq ´[path(..)]´ {"a":[{"b":1}]} => [[],["a"],["a",0],["a",0,"b"]]
del(path_expression) The builtin function del removes a key and its corresponding value from an object.
jq ´del(.foo)´ {"foo": 42, "bar": 9001, "baz": 42} => {"bar": 9001, "baz": 42}
jq ´del(.[1, 2])´ ["foo", "bar", "baz"] => ["foo"]
getpath(PATHS) The builtin function getpath outputs the values in . found at each path in PATHS.
jq ´getpath(["a","b"])´ null => null
jq ´[getpath(["a","b"], ["a","c"])]´ {"a":{"b":0, "c":1}} => [0, 1]
setpath(PATHS; VALUE) The builtin function setpath sets the PATHS in . to VALUE.
jq ´setpath(["a","b"]; 1)´ null => {"a": {"b": 1}}
jq ´setpath(["a","b"]; 1)´ {"a":{"b":0}} => {"a": {"b": 1}}
jq ´setpath([0,"a"]; 1)´ null => [{"a":1}]
delpaths(PATHS) The builtin function delpaths sets the PATHS in .. PATHS must be an array of paths, where each path is an array of strings and numbers.
jq ´delpaths([["a","b"]])´ {"a":{"b":1},"x":{"y":2}} => {"a":{},"x":{"y":2}}
to_entries, from_entries, with_entries These functions convert between an object and an array of key-value pairs. If to_entries is passed an object, then for each k: v entry in the input, the output array includes {"key": k, "value": v}.
from_entries does the opposite conversion, and with_entries(foo) is a shorthand for to_entries | map(foo) | from_entries, useful for doing some operation to all keys and values of an object. from_entries accepts key, Key, name, Name, value and Value as keys.
jq ´to_entries´ {"a": 1, "b": 2} => [{"key":"a", "value":1}, {"key":"b", "value":2}]
jq ´from_entries´ [{"key":"a", "value":1}, {"key":"b", "value":2}] => {"a": 1, "b": 2}
jq ´with_entries(.key |= "KEY_" + .)´ {"a": 1, "b": 2} => {"KEY_a": 1, "KEY_b": 2}
select(boolean_expression) The function select(foo) produces its input unchanged if foo returns true for that input, and produces no output otherwise.
It´s useful for filtering lists: [1,2,3] | map(select(. >= 2)) will give you [2,3].
jq ´map(select(. >= 2))´ [1,5,3,0,7] => [5,3,7]
jq ´.[] | select(.id == "second")´ [{"id": "first", "val": 1}, {"id": "second", "val": 2}] => {"id": "second", "val": 2}
arrays, objects, iterables, booleans, numbers, normals, finites, strings, nulls, values, scalars These built-ins select only inputs that are arrays, objects, iterables (arrays or objects), booleans, numbers, normal numbers, finite numbers, strings, null, non-null values, and non-iterables, respectively.
jq ´.[]|numbers´ [[],{},1,"foo",null,true,false] => 1
empty empty returns no results. None at all. Not even null.
It´s useful on occasion. You´ll know if you need it :)
jq ´1, empty, 2´ null => 1, 2
jq ´[1,2,empty,3]´ null => [1,2,3]
error(message) Produces an error, just like .a applied to values other than null and objects would, but with the given message as the error´s value. Errors can be caught with try/catch; see below.
halt Stops the jq program with no further outputs. jq will exit with exit status 0.
halt_error, halt_error(exit_code) Stops the jq program with no further outputs. The input will be printed on stderr as raw output (i.e., strings will not have double quotes) with no decoration, not even a newline.
The given exit_code (defaulting to 5) will be jq´s exit status.
For example, "Error: somthing went wrong\n"|halt_error(1).
$__loc__ Produces an object with a "file" key and a "line" key, with the filename and line number where $__loc__ occurs, as values.
jq ´try error("\($__loc__)") catch .´ null => "{\"file\":\"<top-level>\",\"line\":1}"
paths, paths(node_filter), leaf_paths paths outputs the paths to all the elements in its input (except it does not output the empty list, representing . itself).
paths(f) outputs the paths to any values for which f is true. That is, paths(numbers) outputs the paths to all numeric values.
leaf_paths is an alias of paths(scalars); leaf_paths is deprecated and will be removed in the next major release.
jq ´[paths]´ [1,[[],{"a":2}]] => [[0],[1],[1,0],[1,1],[1,1,"a"]]
jq ´[paths(scalars)]´ [1,[[],{"a":2}]] => [[0],[1,1,"a"]]
add The filter add takes as input an array, and produces as output the elements of the array added together. This might mean summed, concatenated or merged depending on the types of the elements of the input array - the rules are the same as those for the + operator (described above).
If the input is an empty array, add returns null.
jq ´add´ ["a","b","c"] => "abc"
jq ´add´ [1, 2, 3] => 6
jq ´add´ [] => null
any, any(condition), any(generator; condition) The filter any takes as input an array of boolean values, and produces true as output if any of the elements of the array are true.
If the input is an empty array, any returns false.
The any(condition) form applies the given condition to the elements of the input array.