https://github.com/blob42/yargs
execute commands on columns: a hybrid of xargs and awk
https://github.com/blob42/yargs
awk cli columns map xargs
Last synced: about 2 months ago
JSON representation
execute commands on columns: a hybrid of xargs and awk
- Host: GitHub
- URL: https://github.com/blob42/yargs
- Owner: blob42
- Created: 2022-12-01T21:52:41.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-20T10:38:07.000Z (12 months ago)
- Last Synced: 2025-02-17T21:19:52.165Z (8 months ago)
- Topics: awk, cli, columns, map, xargs
- Language: Rust
- Homepage:
- Size: 56.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
WIP pet project.
# yargs
`yargs` aims to be the `xargs` equivalent to tabular input. It borrows from `awk`
the its ability to work on columns of text and allows for arbitrary
commands to be applied per column in a similar way to `xargs`.The columns are called `fields`. The command to execute on each field is called
an `y-arg`.# Usage
1. passing column yargs as fields
```shell
foo_cmd | yargs --field-1='basename {}' --field-2="awk { print $1 }"
foo_cmd | yargs -f1 'basename {}' -f2 'awk { print $1 }'
```2. Passing `yargs` as positional arguments
```shell
foo_cmd | yargs 'basename {}' 'awk { print $2 }'
```3. skipping fields
```shell
foo_cmd | yargs 'basename {}' - 'awk { print $2 }'
# keeps the second field unchanged
```## Example
input:
field #1 field #2
|--------------------------| |--------------|
/long/path/to/some/ebook.pdf | Title Of Ebook
____
|
example usage: | y-arg
-------------- |
----------------
yargs 'basename {}' "awk { print $1 }"
#OR
yargs -f1 'basename {}' -f2 'awk { print $1 }'would output: `ebook.pdf | Title`
- use colon as delimiter
`yargs -d':' -f1 '...'`
---
[I am using Github under protest](protest.md)