1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-09-10 15:13:52 +02:00

mlr: add page (#2434)

This commit is contained in:
Russ Edwards 2018-10-16 13:26:42 -04:00 committed by Starbeamrainbowlabs
parent 0173d970ef
commit 440bfe44c0

27
pages/common/mlr.md Normal file
View file

@ -0,0 +1,27 @@
# mlr
> Miller is like `awk`, `sed`, `cut`, `join`, and `sort` for name-indexed data such as CSV, TSV, and tabular JSON.
- Pretty-print a CSV file in a tabular format:
`mlr --icsv --opprint cat {{example.csv}}`
- Receive JSON data and pretty print the output:
`echo '{"hello":"world"}' | mlr --ijson --opprint cat`
- Sort alphabetically on a field:
`mlr --icsv --opprint sort -f {{field}} {{example.csv}}`
- Sort in descending numerical order on a field:
`mlr --icsv --opprint sort -nr {{field}} {{example.csv}}`
- Convert CSV to JSON, performing calculations and display those calculations:
`mlr --icsv --ojson put '${{newField1}} = ${{oldFieldA}}/${{oldFieldB}}' {{example.csv}}`
- Receive JSON and format the output as vertical JSON:
`echo '{"hello":"world", "foo":"bar"}' | mlr --ijson --ojson --jvstack cat`