mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
Adding delete command documentation
This commit is contained in:
63
mkdocs/delete.md
Normal file
63
mkdocs/delete.md
Normal file
@@ -0,0 +1,63 @@
|
||||
```
|
||||
yq d <yaml_file|json_file> <path_to_delete>
|
||||
```
|
||||
{!snippets/works_with_json.md!}
|
||||
|
||||
### To Stdout
|
||||
Given a sample.yaml file of:
|
||||
```yaml
|
||||
b:
|
||||
c: 2
|
||||
apples: green
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq d sample.yaml b.c
|
||||
```
|
||||
will output:
|
||||
```yaml
|
||||
b:
|
||||
apples: green
|
||||
```
|
||||
|
||||
### From STDIN
|
||||
```bash
|
||||
cat sample.yaml | yq d - b.c
|
||||
```
|
||||
|
||||
### Deleting array elements
|
||||
Given a sample.yaml file of:
|
||||
```yaml
|
||||
b:
|
||||
c:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq d sample.yaml 'b.c[1]'
|
||||
```
|
||||
will output:
|
||||
```yaml
|
||||
b:
|
||||
c:
|
||||
- 1
|
||||
- 3
|
||||
```
|
||||
|
||||
### Deleting nodes in-place
|
||||
Given a sample.yaml file of:
|
||||
```yaml
|
||||
b:
|
||||
c: 2
|
||||
apples: green
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq d -i sample.yaml b.c
|
||||
```
|
||||
will update the sample.yaml file so that the 'c' node is deleted
|
||||
|
||||
|
||||
{!snippets/keys_with_dots.md!}
|
||||
Reference in New Issue
Block a user