# Delete

## Description

This command allows you to delete data at a given selector.

If the root node is deleted, an empty node of the same type will be output.

Note that if your root node is anything other than an object or array, dasel will output an empty object.

{% hint style="info" %}
Available since `v1.16.0.`
{% endhint %}

## Usage

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

{% hint style="warning" %}
If `--file` is used without `--out` then the source file will be updated.
{% endhint %}

| 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>                                                                                                 |
| `-o`, `--out`                    | <p>Specify the output file. If present, results will be written to the given file. If not present, results will be written to the input file (or stdout if none given).</p><p>To force output to be written to stdout, pass <code>-o stdout</code>or<code>-o -</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="supported-file-types">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>--out</code> and <code>--read</code> flags to determine which parser to use.</p><p>See <a href="supported-file-types">supported file types</a>.</p>   |
| `-p`, `--parser`                 | Shorthand for `-r <value> -w <value>`                                                                                                                                                                                                                                      |
| `-m`, `--multiple`               | <p>Tells dasel to delete multiple items.</p><p>See <a href="flags/multiple">multiple</a>.</p>                                                                                                                                                                              |
| `-s`, `--selector`, `<selector>` | <p>Specify the selector to use. See <a href="../selectors/introduction">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>                                                                                                                |
| `-c`, `--compact`                | This tells dasel to output compact data where possible. E.g. not pretty printing JSON.                                                                                                                                                                                     |
| `--merge-input-documents`        | See [merge input documents](https://daseldocs.tomwright.me/v1/usage/flags/merge-input-documents).                                                                                                                                                                          |
| `--escape-html`                  | See [escape html](https://daseldocs.tomwright.me/v1/usage/flags/escape-html).                                                                                                                                                                                              |

## Example

### Delete property

```shell
$ echo '{
  "name": "Tom",
  "email": "contact@tomwright.me"
}' | dasel delete -p json '.email'
{
  "name": "Tom"
}
```
