← 返回命令列表

Linux command

miller 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Convert CSV to JSON

mlr --csv --ojson cat [file.csv]

Filter records

mlr --csv filter '$[field] > [10]' [file.csv]

Select columns

mlr --csv cut -f [name,age] [file.csv]

Sort by field

mlr --csv sort -f [age] [file.csv]

Aggregate statistics

mlr --csv stats1 -a sum,mean -f [value] -g [category] [file.csv]

Transform field

mlr --csv put '$[total] = $[price] * $[quantity]' [file.csv]

说明

Miller (mlr) is like awk, sed, cut, join, and sort for name-indexed data such as CSV, TSV, and JSON. It's designed for processing structured text data from the command line. Miller handles heterogeneous data formats with consistent syntax.

参数

--csv
CSV input format.
--json
JSON input format.
--ojson
JSON output format.
--icsv --ojson
CSV in, JSON out.
cat
Pass through records.
filter
Select matching records.
cut
Select fields.
sort
Sort records.
put
Add/modify fields.
stats1
Aggregate statistics.

FAQ

What is the miller command used for?

Miller (mlr) is like awk, sed, cut, join, and sort for name-indexed data such as CSV, TSV, and JSON. It's designed for processing structured text data from the command line. Miller handles heterogeneous data formats with consistent syntax.

How do I run a basic miller example?

Run `mlr --csv --ojson cat [file.csv]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --csv do in miller?

CSV input format.