Select

Description

This command allows you to select data from data structures.

It will not modify the source data in any way.

Usage

dasel select -f <file> <selector>

Flags

Flag

Description

-f, --file

Specify the file to query. This is required unless you are piping in data.

If piping in data you can optionally pass -f stdin/-f -.

-r, --read

Specify the parser to use when reading the input data.

This is required if you are piping in data, otherwise dasel will use the given file extension to guess which parser to use.

See supported file types.

-w, --write

Specify the parser to use when writing the output data.

If not provided dasel will attempt to use the --out and --read flags to determine which parser to use.

See supported file types.

-p, --parser

Shorthand for -r <value> -w <value>

-m, --multiple

Tells dasel to select multiple items.

See multiple.

-s, --selector, <selector>

Specify the selector to use. See selectors for more information.

If no selector flag is given, dasel assumes the first argument given is the selector.

This is required.

--plain

By default, dasel formats the output using the specified parser.

If this flag is used no formatting occurs and the results output as a string.

-n, --null

Output null instead of ValueNotFound errors.

See null.

-c, --compact

This tells dasel to output compact data where possible. E.g. not pretty printing JSON.

--length

This tells dasel to output the length of the value found.

  • [1, 2, 3] - 3: The number of elements within the array.

  • {"a": 1, "b": 2} - 2: The number of elements within the map.

  • "Hello there" - 11: The number of characters in the string.

  • Any other values are converted to strings and then treated as such:

    • 12345 - 5: Numbers are converted to strings.

    • 123.45 - 6: Floats/decimals are converted to strings.

    • true - 4: Bools are converted to strings.

--merge-input-documents

See merge input documents.

Example

Select the image within a kubernetes deployment manifest file:

dasel select -f deployment.yaml "spec.template.spec.containers.(name=auth).image"
"tomwright/auth:v1.0.0"

Piping data into the select:

cat deployment.yaml | dasel select -p yaml "spec.template.spec.containers.(name=auth).image"
"tomwright/auth:v1.0.0"