# Select

## Description

This command allows you to select data from data structures.

It will not modify the source data in any way.

## Usage

```shell
dasel select -f <file> <selector>
```

### Flags

| Flag                             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-f`, `--file`                   | <p>Specify the file to query. This is required unless you are piping in data.</p><p>If piping in data you can optionally pass <code>-f stdin</code>/<code>-f -</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `-r`, `--read`                   | <p>Specify the parser to use when reading the input data.</p><p>This is required if you are piping in data, otherwise dasel will use the given file extension to guess which parser to use.</p><p>See <a href="/pages/-MXgNylC4AkvSj351jU3">supported file types</a>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `-w`, `--write`                  | <p>Specify the parser to use when writing the output data.</p><p>If not provided dasel will attempt to use the<code>--read</code> flag to determine which parser to use.</p><p>See <a href="/pages/-MXgNylC4AkvSj351jU3">supported file types</a>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `-p`, `--parser`                 | Shorthand for `-r <value> -w <value>`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `-m`, `--multiple`               | <p>Tells dasel to select multiple items.</p><p>See <a href="/pages/-MXgNylAqqL66l3g7A2u">multiple</a>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `-s`, `--selector`, `<selector>` | <p>Specify the selector to use. See <a href="/pages/-MXgNylFbABKYJMirPOA">selectors</a> for more information.</p><p>If no selector flag is given, dasel assumes the first argument given is the selector.</p><p>This is required.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `--plain`                        | <p>By default, dasel formats the output using the specified parser.</p><p>If this flag is used no formatting occurs and the results output as a string.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `-n`, `--null`                   | <p>Output <code>null</code> instead of <code>ValueNotFound</code> errors.</p><p>See <a href="/pages/-MXgNylB12PQNes7fnNt">null</a>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `-c`, `--compact`                | This tells dasel to output compact data where possible. E.g. not pretty printing JSON.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `--length`                       | <p>This tells dasel to output the length of the value found.</p><ul><li><code>\[1, 2, 3]</code> - <code>3</code>: The number of elements within the array.</li><li><code>{"a": 1, "b": 2}</code> - <code>2</code>: The number of elements within the map.</li><li><code>"Hello there"</code> - <code>11</code>: The number of characters in the string.</li><li><p>Any other values are converted to strings and then treated as such:</p><ul><li><code>12345</code> - <code>5</code>: Numbers are converted to strings.</li><li><code>123.45</code> - <code>6</code>: Floats/decimals are converted to strings.</li><li><code>true</code> - <code>4</code>: Bools are converted to strings.</li></ul></li></ul> |
| `--merge-input-documents`        | See [merge input documents](/v1/usage/flags/merge-input-documents.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `--format`                       | See [format](/v1/usage/flags/format.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `--colour`                       | Colourise output.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `--color`                        | Alias of `--colour.`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `--escape-html`                  | See [escape html](/v1/usage/flags/escape-html.md).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |

## 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"
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://daseldocs.tomwright.me/v1/usage/select.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
