https://github.com/mgla96/yaml-searcher
command line utility for searching through yaml (like yq)
https://github.com/mgla96/yaml-searcher
command-line-utility yaml
Last synced: 10 months ago
JSON representation
command line utility for searching through yaml (like yq)
- Host: GitHub
- URL: https://github.com/mgla96/yaml-searcher
- Owner: Mgla96
- License: apache-2.0
- Created: 2022-01-06T04:00:32.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-30T14:09:05.000Z (about 4 years ago)
- Last Synced: 2025-01-18T10:20:51.199Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yaml-searcher
A command line utility to search through yaml for a specific value.
It reads yaml from stdin and outputs the value you are searching for.
## Examples
Search in yaml for result of field `hello.world`
**yaml-file.yaml**
```yaml
hello:
world: "output"
```
redirect yaml file
```
./yaml-searcher hello.world < yaml-file.yaml
```
pipe in yaml file
```
cat yaml-file.yaml | ./yaml-searcher hello.world
```
Both will return `output`
## Installation
1. Download yaml-searcher
```bash
curl -L https://github.com/mgla96/yaml-searcher/releases/download/v0.1.5/yaml-searcher > yaml-searcher
```
2. Add execution permissions
```bash
chmod +x yaml-searcher
```
3. Place in executable PATH or call directly
## Notes / Gotchas
* zsh uses square brackets for globbing/pattern matching
when passing square brackets in search argument for yaml-searcher, you must either escape them or quote argument
**yaml-file.yaml**
```yaml
hello:
- world: "output"
- world: "output2"
```
**command**
```bash
./yaml-searcher 'hello[0]' < yaml-file.yaml
```
```bash
./yaml-searcher hello\[0\] < yaml-file.yaml
```
**returns**
```bash
world: output
```