# ysed

> YAML sed: Command line YAML editor.

Latest version **0.0.7** (published 2022-01-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install ysed
pnpm add ysed
yarn add ysed
bun add ysed
```

Provides the command `ysed`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2022-01-07 |
| First published | 2019-11-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | chakradarraju@gmail.com |
| Maintainers | chakradarraju |
| Keywords | ysed, yaml, sed, kubernetes, cli |

## Links

- npm: https://www.npmjs.com/package/ysed
- Repository: https://github.com/chakradarraju/ysed
- Homepage: https://github.com/chakradarraju/ysed#readme
- Issues: https://github.com/chakradarraju/ysed/issues
- npm.io page: https://npm.io/package/ysed

## Dependencies (1)

- [yaml](https://npm.io/package/yaml.md) ^1.7.2

## Alternatives

- [monaco-yaml](https://npm.io/package/monaco-yaml.md) — 420.1K weekly downloads
- [@crewx/workflow](https://npm.io/package/@crewx/workflow.md) — 3.1K weekly downloads
- [yaml-cat](https://npm.io/package/yaml-cat.md) — 38 weekly downloads
- [nunjucks-in-yaml](https://npm.io/package/nunjucks-in-yaml.md) — 9 weekly downloads
- [shopify-symlinks](https://npm.io/package/shopify-symlinks.md) — 3 weekly downloads

## Recent versions

- 0.0.7 (latest) — 2022-01-07
- 0.0.6 — 2019-11-25
- 0.0.5 — 2019-11-25
- 0.0.4 — 2019-11-24
- 0.0.3 — 2019-11-23
- 0.0.2 — 2019-11-23
- 0.0.1 — 2019-11-23

## README

# YAML sed

YAML sed helps you to modify yaml files from command line.

# Installation

`npm i -g ysed`

To install npm see [https://www.npmjs.com/get-npm](https://www.npmjs.com/get-npm).

# Usage

`ysed (<some_yaml_file.yaml>|<some_ysed_file.ysed>) [updates]`

ysed reads the yaml file, applies specified updates and writes updated yaml into stdout.

This can be used with kubectl:

`ysed <yaml> [updates] | kubectl apply -f -`

## Supported updates

### Update specific path
`some.path[index].to.element=new_value`: If an element matches given path exactly in any YAML document in input file, value of that field will be updated to `new_value`.
### Update an environment variable
`env[ENV_VARIABLE_NAME]=new_value`: Any environment variable in containers match ENV_VARIABLE_NAME, then it's value will be updated to `new_value`.
### Update matching values
`value[old_value]=new_value`: Any value matching old_value will be updated to `new_value`.
### Updates config
`update_file.ysed`: Each line in update_file will be processed like a command line update. If passed instead of yaml file as first parameter to ysed, then first line in ysed file is expected to be relative path to yaml template.

## Example

```
file: my_yaml
for: demonstration
content:
  field1: value1
  field2: value2
  containers:
  - name: busybox1
    env:
    - name: VAR1
      value: value3
    - name: VAR2
      value: value4
---
file: doc2
for: demonstration
content:
  field3: value5
  field4: value6
  containers:
  - name: busybox2
    env:
    - name: VAR3
      value: value7
    - name: VAR4
      value: value8
    - name: VAR5
      value: value9
```

`ysed demo.yaml content.containers[0].env[2].value=new_value1 env[VAR4]=new_value2`
will print:
```
- file: my_yaml
  for: demonstration
  content:
    field1: value1
    field2: value2
    containers:
      - name: busybox1
        env:
          - name: VAR1
            value: value3
          - name: VAR2
            value: value4
- file: doc2
  for: demonstration
  content:
    field3: value5
    field4: value6
    containers:
      - name: busybox2
        env:
          - name: VAR3
            value: value7
          - name: VAR4
            value: new_value2
          - name: VAR5
            value: new_value1
```

# Feature requests

If you've specific feature requests, send pull request in [Github](https://github.com/chakradarraju/ysed) or message [me](https://chakradarraju.github.io/).

---
_Source: https://npm.io/package/ysed · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
