| Crates.io | d-rs |
| lib.rs | d-rs |
| version | 0.2.0 |
| created_at | 2023-05-31 10:54:46.860085+00 |
| updated_at | 2023-05-31 10:57:32.948882+00 |
| description | stream processing utilities for the command line |
| homepage | |
| repository | |
| max_upload_size | |
| id | 878688 |
| size | 35,884 |
d stands for data. d-rs is a combination of features from grep, awk
sed, and other unix tools, to easily edit piped data.
Let's say a file exists with the following contents:
# Hours
x: 3 hours
y: 3.5 hours
z: 15 hours
w: 1.5 hours
You can use d to find how many hours there are in total with:
cat hours.txt | d f float | d r sum
Gives 23.
So what happened here?
d has 4 main subcommands
Each of the commands can be abbreviated (by f, m, r or s respectively).
So what happened in the example? first we find all the floats, then we reduce
using the sum operator.
In general, you can
using d m p (d map python) you can tell d to run a line of python
for every line in the input. Your line will be ran in a context where:
i or inp variable available which contains the current lineo or out variable which when written to becomes the result of the expression (using __repr__ to convert it to a string)o/out are ignored, to prevent multiple outputs from the expression.No state is kept between mapping lines.
500KiB) and automatically convert to their base units (500Kib --> 512000)