From ca199593ee4c5c84c0dd8a2e46de22253eac4897 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sat, 6 Aug 2016 11:58:31 -0400 Subject: [PATCH] doc neaten --- c/mapping/mlr_dsl_cst.c | 103 +++++++++++++++++++++++---------------- c/todo.txt | 14 +++++- doc/manpage.html | 105 ++++++++++++++++++++++++---------------- doc/manpage.txt | 105 ++++++++++++++++++++++++---------------- doc/mlr.1 | 105 ++++++++++++++++++++++++---------------- doc/reference.html | 99 ++++++++++++++++++++++--------------- 6 files changed, 322 insertions(+), 209 deletions(-) diff --git a/c/mapping/mlr_dsl_cst.c b/c/mapping/mlr_dsl_cst.c index a2733959d..4e0b02ec0 100644 --- a/c/mapping/mlr_dsl_cst.c +++ b/c/mapping/mlr_dsl_cst.c @@ -2592,25 +2592,25 @@ static void mlr_dsl_filter_keyword_usage(FILE* ostream) { fprintf(ostream, "filter: includes/excludes the record in the output record stream.\n" "\n" - " Example: mlr put 'filter (NR == 2 || $x > 5.4)'.\n" + " Example: mlr --from myfile.dat put 'filter (NR == 2 || $x > 5.4)'\n" "\n" " Instead of put with 'filter false' you can simply use put -q. The following\n" " uses the input record to accumulate data but only prints the running sum\n" " without printing the input record:\n" "\n" - " Example: mlr put -q '@running_sum += $x * $y; emit @running_sum'.\n"); + " Example: mlr --from myfile.dat put -q '@running_sum += $x * $y; emit @running_sum'\n"); } static void mlr_dsl_unset_keyword_usage(FILE* ostream) { fprintf(ostream, "unset: clears field(s) from the current record, or an out-of-stream variable.\n" "\n" - " Example: mlr put 'unset $x'\n" - " Example: mlr put 'unset $*'\n" - " Example: mlr put 'for (k, v in $*) { if (k =~ \"a.*\") { unset $[k] } }'\n" - " Example: mlr put '...; unset @sums'\n" - " Example: mlr put '...; unset @sums[\"green\"]'\n" - " Example: mlr put '...; unset @*'\n"); + " Example: mlr --from myfile.dat put 'unset $x'\n" + " Example: mlr --from myfile.dat put 'unset $*'\n" + " Example: mlr --from myfile.dat put 'for (k, v in $*) { if (k =~ \"a.*\") { unset $[k] } }'\n" + " Example: mlr --from myfile.dat put '...; unset @sums'\n" + " Example: mlr --from myfile.dat put '...; unset @sums[\"green\"]'\n" + " Example: mlr --from myfile.dat put '...; unset @*'\n"); } static void mlr_dsl_tee_keyword_usage(FILE* ostream) { @@ -2623,10 +2623,11 @@ static void mlr_dsl_tee_keyword_usage(FILE* ostream) { " process which will process the data. There will be one subordinate process for\n" " each distinct value of the piped-to command.\n" "\n" - " Example: mlr put 'tee > \"/tmp/data-\".$a, $*'\n" - " Example: mlr put 'tee >> \"/tmp/data-\".$a.$b, $*'\n" - " Example: mlr put -q 'tee | \"tr \[a-z\\] \[A-Z\\]\", $*'\n" - " Example: mlr put -q 'tee | \"tr \[a-z\\] \[A-Z\\] > /tmp/data-\".$a, $*'\n"); + " Example: mlr --from myfile.dat put 'tee > \"/tmp/data-\".$a, $*'\n" + " Example: mlr --from myfile.dat put 'tee >> \"/tmp/data-\".$a.$b, $*'\n" + " Example: mlr --from myfile.dat put 'tee > stderr, $*'\n" + " Example: mlr --from myfile.dat put -q 'tee | \"tr \[a-z\\] \[A-Z\\]\", $*'\n" + " Example: mlr --from myfile.dat put -q 'tee | \"tr \[a-z\\] \[A-Z\\] > /tmp/data-\".$a, $*'\n"); } static void mlr_dsl_emit_keyword_usage(FILE* ostream) { @@ -2640,12 +2641,13 @@ static void mlr_dsl_emit_keyword_usage(FILE* ostream) { " record. The | is for pipe to a process which will process the data. There will\n" " be one subordinate process for each distinct value of the piped-to command.\n" "\n" - " Example: mlr put '... ; emit @sums'\n" - " Example: mlr put '... ; emit @sums, \"index1\", \"index2\"'\n" - " Example: mlr put '... ; emit @*, \"index1\", \"index2\"'\n" - " Example: mlr put '... ; emit > \"mytap.dat\", @*, \"index1\", \"index2\"'\n" - " Example: mlr put '... ; emit >> \"mytap.dat\", @*, \"index1\", \"index2\"'\n" - " Example: mlr put '... ; emit | \"grep somepattern\", @*, \"index1\", \"index2\"'\n" + " Example: mlr --from myfile.dat put '... ; emit @sums'\n" + " Example: mlr --from myfile.dat put '... ; emit @sums, \"index1\", \"index2\"'\n" + " Example: mlr --from myfile.dat put '... ; emit @*, \"index1\", \"index2\"'\n" + " Example: mlr --from myfile.dat put '... ; emit > \"mytap.dat\", @*, \"index1\", \"index2\"'\n" + " Example: mlr --from myfile.dat put '... ; emit >> \"mytap.dat\", @*, \"index1\", \"index2\"'\n" + " Example: mlr --from myfile.dat put '... ; emit > stderr, @*, \"index1\", \"index2\"'\n" + " Example: mlr --from myfile.dat put '... ; emit | \"grep somepattern\", @*, \"index1\", \"index2\"'\n" "\n" " Please see http://johnkerl.org/miller/doc for more information.\n"); } @@ -2662,12 +2664,13 @@ static void mlr_dsl_emitp_keyword_usage(FILE* ostream) { " record. The | is for pipe to a process which will process the data. There will\n" " be one subordinate process for each distinct value of the piped-to command.\n" "\n" - " Example: mlr put '... ; emitp @sums'\n" - " Example: mlr put '... ; emitp @sums, \"index1\", \"index2\"'\n" - " Example: mlr put '... ; emitp @*, \"index1\", \"index2\"'\n" - " Example: mlr put '... ; emitp > \"mytap.dat\", @*, \"index1\", \"index2\"'\n" - " Example: mlr put '... ; emitp >> \"mytap.dat\", @*, \"index1\", \"index2\"'\n" - " Example: mlr put '... ; emitp | \"grep somepattern\", @*, \"index1\", \"index2\"'\n" + " Example: mlr --from myfile.dat put '... ; emitp @sums'\n" + " Example: mlr --from myfile.dat put '... ; emitp @sums, \"index1\", \"index2\"'\n" + " Example: mlr --from myfile.dat put '... ; emitp @*, \"index1\", \"index2\"'\n" + " Example: mlr --from myfile.dat put '... ; emitp > \"mytap.dat\", @*, \"index1\", \"index2\"'\n" + " Example: mlr --from myfile.dat put '... ; emitp >> \"mytap.dat\", @*, \"index1\", \"index2\"'\n" + " Example: mlr --from myfile.dat put '... ; emitp > stderr, @*, \"index1\", \"index2\"'\n" + " Example: mlr --from myfile.dat put '... ; emitp | \"grep somepattern\", @*, \"index1\", \"index2\"'\n" "\n" " Please see http://johnkerl.org/miller/doc for more information.\n"); } @@ -2683,12 +2686,13 @@ static void mlr_dsl_emitf_keyword_usage(FILE* ostream) { " record. The | is for pipe to a process which will process the data. There will\n" " be one subordinate process for each distinct value of the piped-to command.\n" "\n" - " Example: mlr put '... ; emitf @a'\n" - " Example: mlr put '... ; emitf @a, @b, @c'\n" - " Example: mlr put '... ; emitf > \"mytap.dat\", @a, @b, @c'\n" - " Example: mlr put '... ; emitf >> \"mytap.dat\", @a, @b, @c'\n" - " Example: mlr put '... ; emitf | \"grep somepattern\", @a, @b, @c'\n" - " Example: mlr put '... ; emitf | \"grep somepattern > mytap.dat\", @a, @b, @c'\n" + " Example: mlr --from myfile.dat put '... ; emitf @a'\n" + " Example: mlr --from myfile.dat put '... ; emitf @a, @b, @c'\n" + " Example: mlr --from myfile.dat put '... ; emitf > \"mytap.dat\", @a, @b, @c'\n" + " Example: mlr --from myfile.dat put '... ; emitf >> \"mytap.dat\", @a, @b, @c'\n" + " Example: mlr --from myfile.dat put '... ; emitf > stderr, @a, @b, @c'\n" + " Example: mlr --from myfile.dat put '... ; emitf | \"grep somepattern\", @a, @b, @c'\n" + " Example: mlr --from myfile.dat put '... ; emitf | \"grep somepattern > mytap.dat\", @a, @b, @c'\n" "\n" " Please see http://johnkerl.org/miller/doc for more information.\n"); } @@ -2696,49 +2700,64 @@ static void mlr_dsl_emitf_keyword_usage(FILE* ostream) { static void mlr_dsl_dump_keyword_usage(FILE* ostream) { fprintf(ostream, "dump: prints all currently defined out-of-stream variables immediately\n" - " to stdout as JSON.\n"); + " to stdout as JSON.\n" + "\n" + " With >, >>, or |, the data do not become part of the output record stream but\n" + " are instead redirected. The > and >> are for write and append, as in the\n" + " shell, but (as with awk) the file-overwrite for > is on first write, not per\n" + " record. The | is for pipe to a process which will process the data. There will\n" + " be one subordinate process for each distinct value of the piped-to command.\n" + "\n" + " Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump }'\n" + " Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump > \"mytap.dat\"}'\n" + " Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump >> \"mytap.dat\"}'\n" + " Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump | \"jq .[]\"}'\n"); } static void mlr_dsl_edump_keyword_usage(FILE* ostream) { fprintf(ostream, "edump: prints all currently defined out-of-stream variables immediately\n" - " to stderr as JSON.\n"); + " to stderr as JSON.\n" + "\n" + " Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { edump }'\n"); } static void mlr_dsl_print_keyword_usage(FILE* ostream) { fprintf(ostream, "print: prints expression immediately to stdout.\n" - " Example: mlr put -q 'print \"The sum of x and y is \".($x+$y)'.\n" - " Example: mlr put -q 'for (k, v in $*) { print k . \" => \" . v }'.\n"); + " Example: mlr --from myfile.dat put -q 'print \"The sum of x and y is \".($x+$y)'\n" + " Example: mlr --from myfile.dat put -q 'for (k, v in $*) { print k . \" => \" . v }'\n" + " Example: mlr --from myfile.dat put '(NR %% 1000 == 0) { print > stderr, \"Checkpoint \".NR}'\n"); } static void mlr_dsl_printn_keyword_usage(FILE* ostream) { fprintf(ostream, "printn: prints expression immediately to stdout, without trailing newline.\n" - " Example: mlr put -q 'printn \"The sum of x and y is \".($x+$y); print \"\"'.\n"); + " Example: mlr --from myfile.dat put -q 'printn \".\"; end { print \"\" }'\n"); } static void mlr_dsl_eprint_keyword_usage(FILE* ostream) { fprintf(ostream, "eprint: prints expression immediately to stderr.\n" - " Example: mlr put -q 'eprint \"The sum of x and y is \".($x+$y)'.\n" - " Example: mlr put -q 'for (k, v in $*) { eprint k . \" => \" . v }'.\n"); + " Example: mlr --from myfile.dat put -q 'eprint \"The sum of x and y is \".($x+$y)'\n" + " Example: mlr --from myfile.dat put -q 'for (k, v in $*) { eprint k . \" => \" . v }'\n" + " Example: mlr --from myfile.dat put '(NR %% 1000 == 0) { eprint \"Checkpoint \".NR}'\n"); } static void mlr_dsl_eprintn_keyword_usage(FILE* ostream) { fprintf(ostream, "eprintn: prints expression immediately to stderr, without trailing newline.\n" - " Example: mlr put -q 'eprintn \"The sum of x and y is \".($x+$y)'; eprint \"\".\n"); + " Example: mlr --from myfile.dat put -q 'eprintn \"The sum of x and y is \".($x+$y)'; eprint \"\"\n"); } static void mlr_dsl_stdout_keyword_usage(FILE* ostream) { fprintf(ostream, - "stdout: Used for tee, emit, emitf, emitp, and dump in place of filename to\n" - " print to standard output.\n"); + "stdout: Used for tee, emit, emitf, emitp, print, and dump in place of filename\n" + " to print to standard output.\n"); } static void mlr_dsl_stderr_keyword_usage(FILE* ostream) { fprintf(ostream, - "stderr: Used for tee, emit, emitf, emitp, and dump in place of filename to\n" - " print to standard error.\n"); + "stderr: Used for tee, emit, emitf, emitp, print, and dump in place of filename\n" + " to print to standard error.\n"); } diff --git a/c/todo.txt b/c/todo.txt index 529a763e0..2aa59632a 100644 --- a/c/todo.txt +++ b/c/todo.txt @@ -1,7 +1,17 @@ ================================================================ BUGFIXES -:D +* + mlr --from myfile.dat put 'tee > stderr, $*' + mlr: internal coding error detected in file mapping/rval_expr_evaluators.c at line 66. + + mlr --from myfile.dat put '@v[NR][NR]=$* ; emit > stderr, @*, "index1", "index2"' + mlr: internal coding error detected in file mapping/rval_expr_evaluators.c at line 66. + + mlr --from myfile.dat put '@v[NR][NR]=$*; emit | "grep somepattern", @*, "index1", "index2"' + ... + pclose: Undefined error: 0 + mlr: pclose error on "grep somepattern". ================================================================ TOP OF LIST: @@ -18,8 +28,10 @@ TOP OF LIST: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - COMMON: +! flesh out ...'s in mlr -k's ? print/dump end with OFS ! ! clean up all mlr -k's +! --oflags note to mlr -k's ! stderr UTs ! * mlr -k needs >/>>/| examples incl. stdout/stderr/file/cmd. also some subset at mlr put -h. * kw stdout/stderr & to mlr -k / mlh / mld; also to release notes (not avail as boundvars & what happens if tried: diff --git a/doc/manpage.html b/doc/manpage.html index 849ea7e9b..f58645978 100644 --- a/doc/manpage.html +++ b/doc/manpage.html @@ -1478,23 +1478,23 @@ KEYWORDS FOR PUT filter filter: includes/excludes the record in the output record stream. - Example: mlr put 'filter (NR == 2 || $x > 5.4)'. + Example: mlr --from myfile.dat put 'filter (NR == 2 || $x > 5.4)' Instead of put with 'filter false' you can simply use put -q. The following uses the input record to accumulate data but only prints the running sum without printing the input record: - Example: mlr put -q '@running_sum += $x * $y; emit @running_sum'. + Example: mlr --from myfile.dat put -q '@running_sum += $x * $y; emit @running_sum' unset unset: clears field(s) from the current record, or an out-of-stream variable. - Example: mlr put 'unset $x' - Example: mlr put 'unset $*' - Example: mlr put 'for (k, v in $*) { if (k =~ "a.*") { unset $[k] } }' - Example: mlr put '...; unset @sums' - Example: mlr put '...; unset @sums["green"]' - Example: mlr put '...; unset @*' + Example: mlr --from myfile.dat put 'unset $x' + Example: mlr --from myfile.dat put 'unset $*' + Example: mlr --from myfile.dat put 'for (k, v in $*) { if (k =~ "a.*") { unset $[k] } }' + Example: mlr --from myfile.dat put '...; unset @sums' + Example: mlr --from myfile.dat put '...; unset @sums["green"]' + Example: mlr --from myfile.dat put '...; unset @*' tee tee: prints the current record to specified file. @@ -1505,10 +1505,11 @@ KEYWORDS FOR PUT process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put 'tee > "/tmp/data-".$a, $*' - Example: mlr put 'tee >> "/tmp/data-".$a.$b, $*' - Example: mlr put -q 'tee | "tr [a-z\] [A-Z\]", $*' - Example: mlr put -q 'tee | "tr [a-z\] [A-Z\] > /tmp/data-".$a, $*' + Example: mlr --from myfile.dat put 'tee > "/tmp/data-".$a, $*' + Example: mlr --from myfile.dat put 'tee >> "/tmp/data-".$a.$b, $*' + Example: mlr --from myfile.dat put 'tee > stderr, $*' + Example: mlr --from myfile.dat put -q 'tee | "tr [a-z\] [A-Z\]", $*' + Example: mlr --from myfile.dat put -q 'tee | "tr [a-z\] [A-Z\] > /tmp/data-".$a, $*' emit emit: inserts an out-of-stream variable into the output record stream. Hashmap @@ -1520,12 +1521,13 @@ KEYWORDS FOR PUT record. The | is for pipe to a process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put '... ; emit @sums' - Example: mlr put '... ; emit @sums, "index1", "index2"' - Example: mlr put '... ; emit @*, "index1", "index2"' - Example: mlr put '... ; emit > "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emit >> "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emit | "grep somepattern", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit @sums' + Example: mlr --from myfile.dat put '... ; emit @sums, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit > "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit >> "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit > stderr, @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit | "grep somepattern", @*, "index1", "index2"' Please see http://johnkerl.org/miller/doc for more information. @@ -1540,12 +1542,13 @@ KEYWORDS FOR PUT record. The | is for pipe to a process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put '... ; emitp @sums' - Example: mlr put '... ; emitp @sums, "index1", "index2"' - Example: mlr put '... ; emitp @*, "index1", "index2"' - Example: mlr put '... ; emitp > "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emitp >> "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emitp | "grep somepattern", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp @sums' + Example: mlr --from myfile.dat put '... ; emitp @sums, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp > "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp >> "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp > stderr, @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp | "grep somepattern", @*, "index1", "index2"' Please see http://johnkerl.org/miller/doc for more information. @@ -1559,12 +1562,13 @@ KEYWORDS FOR PUT record. The | is for pipe to a process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put '... ; emitf @a' - Example: mlr put '... ; emitf @a, @b, @c' - Example: mlr put '... ; emitf > "mytap.dat", @a, @b, @c' - Example: mlr put '... ; emitf >> "mytap.dat", @a, @b, @c' - Example: mlr put '... ; emitf | "grep somepattern", @a, @b, @c' - Example: mlr put '... ; emitf | "grep somepattern > mytap.dat", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf @a' + Example: mlr --from myfile.dat put '... ; emitf @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf > "mytap.dat", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf >> "mytap.dat", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf > stderr, @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf | "grep somepattern", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf | "grep somepattern > mytap.dat", @a, @b, @c' Please see http://johnkerl.org/miller/doc for more information. @@ -1572,37 +1576,54 @@ KEYWORDS FOR PUT dump: prints all currently defined out-of-stream variables immediately to stdout as JSON. + With >, >>, or |, the data do not become part of the output record stream but + are instead redirected. The > and >> are for write and append, as in the + shell, but (as with awk) the file-overwrite for > is on first write, not per + record. The | is for pipe to a process which will process the data. There will + be one subordinate process for each distinct value of the piped-to command. + + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump }' + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump > "mytap.dat"}' + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump >> "mytap.dat"}' + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump | "jq .[]"}' + edump edump: prints all currently defined out-of-stream variables immediately to stderr as JSON. + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { edump }' + print print: prints expression immediately to stdout. - Example: mlr put -q 'print "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { print k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'print "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { print k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { print > stderr, "Checkpoint ".NR}' printn print: prints expression immediately to stdout. - Example: mlr put -q 'print "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { print k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'print "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { print k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { print > stderr, "Checkpoint ".NR}' eprint eprint: prints expression immediately to stderr. - Example: mlr put -q 'eprint "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { eprint k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'eprint "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { eprint k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { eprint "Checkpoint ".NR}' eprintn eprint: prints expression immediately to stderr. - Example: mlr put -q 'eprint "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { eprint k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'eprint "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { eprint k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { eprint "Checkpoint ".NR}' stdout - stdout: Used for tee, emit, emitf, emitp, and dump in place of filename to - print to standard output. + stdout: Used for tee, emit, emitf, emitp, print, and dump in place of filename + to print to standard output. stderr - stderr: Used for tee, emit, emitf, emitp, and dump in place of filename to - print to standard error. + stderr: Used for tee, emit, emitf, emitp, print, and dump in place of filename + to print to standard error. AUTHOR Miller is written by John Kerl <kerl.john.r@gmail.com>. diff --git a/doc/manpage.txt b/doc/manpage.txt index 0d71d6951..af2acfb1b 100644 --- a/doc/manpage.txt +++ b/doc/manpage.txt @@ -1332,23 +1332,23 @@ KEYWORDS FOR PUT filter filter: includes/excludes the record in the output record stream. - Example: mlr put 'filter (NR == 2 || $x > 5.4)'. + Example: mlr --from myfile.dat put 'filter (NR == 2 || $x > 5.4)' Instead of put with 'filter false' you can simply use put -q. The following uses the input record to accumulate data but only prints the running sum without printing the input record: - Example: mlr put -q '@running_sum += $x * $y; emit @running_sum'. + Example: mlr --from myfile.dat put -q '@running_sum += $x * $y; emit @running_sum' unset unset: clears field(s) from the current record, or an out-of-stream variable. - Example: mlr put 'unset $x' - Example: mlr put 'unset $*' - Example: mlr put 'for (k, v in $*) { if (k =~ "a.*") { unset $[k] } }' - Example: mlr put '...; unset @sums' - Example: mlr put '...; unset @sums["green"]' - Example: mlr put '...; unset @*' + Example: mlr --from myfile.dat put 'unset $x' + Example: mlr --from myfile.dat put 'unset $*' + Example: mlr --from myfile.dat put 'for (k, v in $*) { if (k =~ "a.*") { unset $[k] } }' + Example: mlr --from myfile.dat put '...; unset @sums' + Example: mlr --from myfile.dat put '...; unset @sums["green"]' + Example: mlr --from myfile.dat put '...; unset @*' tee tee: prints the current record to specified file. @@ -1359,10 +1359,11 @@ KEYWORDS FOR PUT process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put 'tee > "/tmp/data-".$a, $*' - Example: mlr put 'tee >> "/tmp/data-".$a.$b, $*' - Example: mlr put -q 'tee | "tr [a-z\] [A-Z\]", $*' - Example: mlr put -q 'tee | "tr [a-z\] [A-Z\] > /tmp/data-".$a, $*' + Example: mlr --from myfile.dat put 'tee > "/tmp/data-".$a, $*' + Example: mlr --from myfile.dat put 'tee >> "/tmp/data-".$a.$b, $*' + Example: mlr --from myfile.dat put 'tee > stderr, $*' + Example: mlr --from myfile.dat put -q 'tee | "tr [a-z\] [A-Z\]", $*' + Example: mlr --from myfile.dat put -q 'tee | "tr [a-z\] [A-Z\] > /tmp/data-".$a, $*' emit emit: inserts an out-of-stream variable into the output record stream. Hashmap @@ -1374,12 +1375,13 @@ KEYWORDS FOR PUT record. The | is for pipe to a process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put '... ; emit @sums' - Example: mlr put '... ; emit @sums, "index1", "index2"' - Example: mlr put '... ; emit @*, "index1", "index2"' - Example: mlr put '... ; emit > "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emit >> "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emit | "grep somepattern", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit @sums' + Example: mlr --from myfile.dat put '... ; emit @sums, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit > "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit >> "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit > stderr, @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit | "grep somepattern", @*, "index1", "index2"' Please see http://johnkerl.org/miller/doc for more information. @@ -1394,12 +1396,13 @@ KEYWORDS FOR PUT record. The | is for pipe to a process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put '... ; emitp @sums' - Example: mlr put '... ; emitp @sums, "index1", "index2"' - Example: mlr put '... ; emitp @*, "index1", "index2"' - Example: mlr put '... ; emitp > "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emitp >> "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emitp | "grep somepattern", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp @sums' + Example: mlr --from myfile.dat put '... ; emitp @sums, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp > "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp >> "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp > stderr, @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp | "grep somepattern", @*, "index1", "index2"' Please see http://johnkerl.org/miller/doc for more information. @@ -1413,12 +1416,13 @@ KEYWORDS FOR PUT record. The | is for pipe to a process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put '... ; emitf @a' - Example: mlr put '... ; emitf @a, @b, @c' - Example: mlr put '... ; emitf > "mytap.dat", @a, @b, @c' - Example: mlr put '... ; emitf >> "mytap.dat", @a, @b, @c' - Example: mlr put '... ; emitf | "grep somepattern", @a, @b, @c' - Example: mlr put '... ; emitf | "grep somepattern > mytap.dat", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf @a' + Example: mlr --from myfile.dat put '... ; emitf @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf > "mytap.dat", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf >> "mytap.dat", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf > stderr, @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf | "grep somepattern", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf | "grep somepattern > mytap.dat", @a, @b, @c' Please see http://johnkerl.org/miller/doc for more information. @@ -1426,37 +1430,54 @@ KEYWORDS FOR PUT dump: prints all currently defined out-of-stream variables immediately to stdout as JSON. + With >, >>, or |, the data do not become part of the output record stream but + are instead redirected. The > and >> are for write and append, as in the + shell, but (as with awk) the file-overwrite for > is on first write, not per + record. The | is for pipe to a process which will process the data. There will + be one subordinate process for each distinct value of the piped-to command. + + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump }' + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump > "mytap.dat"}' + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump >> "mytap.dat"}' + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump | "jq .[]"}' + edump edump: prints all currently defined out-of-stream variables immediately to stderr as JSON. + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { edump }' + print print: prints expression immediately to stdout. - Example: mlr put -q 'print "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { print k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'print "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { print k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { print > stderr, "Checkpoint ".NR}' printn print: prints expression immediately to stdout. - Example: mlr put -q 'print "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { print k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'print "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { print k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { print > stderr, "Checkpoint ".NR}' eprint eprint: prints expression immediately to stderr. - Example: mlr put -q 'eprint "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { eprint k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'eprint "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { eprint k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { eprint "Checkpoint ".NR}' eprintn eprint: prints expression immediately to stderr. - Example: mlr put -q 'eprint "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { eprint k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'eprint "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { eprint k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { eprint "Checkpoint ".NR}' stdout - stdout: Used for tee, emit, emitf, emitp, and dump in place of filename to - print to standard output. + stdout: Used for tee, emit, emitf, emitp, print, and dump in place of filename + to print to standard output. stderr - stderr: Used for tee, emit, emitf, emitp, and dump in place of filename to - print to standard error. + stderr: Used for tee, emit, emitf, emitp, print, and dump in place of filename + to print to standard error. AUTHOR Miller is written by John Kerl . diff --git a/doc/mlr.1 b/doc/mlr.1 index 2945f710b..12fd0d9e9 100644 --- a/doc/mlr.1 +++ b/doc/mlr.1 @@ -2299,13 +2299,13 @@ e.g. 1440768801.748936. .nf filter: includes/excludes the record in the output record stream. - Example: mlr put 'filter (NR == 2 || $x > 5.4)'. + Example: mlr --from myfile.dat put 'filter (NR == 2 || $x > 5.4)' Instead of put with 'filter false' you can simply use put -q. The following uses the input record to accumulate data but only prints the running sum without printing the input record: - Example: mlr put -q '@running_sum += $x * $y; emit @running_sum'. + Example: mlr --from myfile.dat put -q '@running_sum += $x * $y; emit @running_sum' .fi .if n \{\ .RE @@ -2316,12 +2316,12 @@ filter: includes/excludes the record in the output record stream. .nf unset: clears field(s) from the current record, or an out-of-stream variable. - Example: mlr put 'unset $x' - Example: mlr put 'unset $*' - Example: mlr put 'for (k, v in $*) { if (k =~ "a.*") { unset $[k] } }' - Example: mlr put '...; unset @sums' - Example: mlr put '...; unset @sums["green"]' - Example: mlr put '...; unset @*' + Example: mlr --from myfile.dat put 'unset $x' + Example: mlr --from myfile.dat put 'unset $*' + Example: mlr --from myfile.dat put 'for (k, v in $*) { if (k =~ "a.*") { unset $[k] } }' + Example: mlr --from myfile.dat put '...; unset @sums' + Example: mlr --from myfile.dat put '...; unset @sums["green"]' + Example: mlr --from myfile.dat put '...; unset @*' .fi .if n \{\ .RE @@ -2338,10 +2338,11 @@ tee: prints the current record to specified file. process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put 'tee > "/tmp/data-".$a, $*' - Example: mlr put 'tee >> "/tmp/data-".$a.$b, $*' - Example: mlr put -q 'tee | "tr [a-z\e] [A-Z\e]", $*' - Example: mlr put -q 'tee | "tr [a-z\e] [A-Z\e] > /tmp/data-".$a, $*' + Example: mlr --from myfile.dat put 'tee > "/tmp/data-".$a, $*' + Example: mlr --from myfile.dat put 'tee >> "/tmp/data-".$a.$b, $*' + Example: mlr --from myfile.dat put 'tee > stderr, $*' + Example: mlr --from myfile.dat put -q 'tee | "tr [a-z\e] [A-Z\e]", $*' + Example: mlr --from myfile.dat put -q 'tee | "tr [a-z\e] [A-Z\e] > /tmp/data-".$a, $*' .fi .if n \{\ .RE @@ -2359,12 +2360,13 @@ emit: inserts an out-of-stream variable into the output record stream. Hashmap record. The | is for pipe to a process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put '... ; emit @sums' - Example: mlr put '... ; emit @sums, "index1", "index2"' - Example: mlr put '... ; emit @*, "index1", "index2"' - Example: mlr put '... ; emit > "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emit >> "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emit | "grep somepattern", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit @sums' + Example: mlr --from myfile.dat put '... ; emit @sums, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit > "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit >> "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit > stderr, @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit | "grep somepattern", @*, "index1", "index2"' Please see http://johnkerl.org/miller/doc for more information. .fi @@ -2385,12 +2387,13 @@ emitp: inserts an out-of-stream variable into the output record stream. record. The | is for pipe to a process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put '... ; emitp @sums' - Example: mlr put '... ; emitp @sums, "index1", "index2"' - Example: mlr put '... ; emitp @*, "index1", "index2"' - Example: mlr put '... ; emitp > "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emitp >> "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emitp | "grep somepattern", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp @sums' + Example: mlr --from myfile.dat put '... ; emitp @sums, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp > "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp >> "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp > stderr, @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp | "grep somepattern", @*, "index1", "index2"' Please see http://johnkerl.org/miller/doc for more information. .fi @@ -2410,12 +2413,13 @@ emitf: inserts non-indexed out-of-stream variable(s) side-by-side into the record. The | is for pipe to a process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put '... ; emitf @a' - Example: mlr put '... ; emitf @a, @b, @c' - Example: mlr put '... ; emitf > "mytap.dat", @a, @b, @c' - Example: mlr put '... ; emitf >> "mytap.dat", @a, @b, @c' - Example: mlr put '... ; emitf | "grep somepattern", @a, @b, @c' - Example: mlr put '... ; emitf | "grep somepattern > mytap.dat", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf @a' + Example: mlr --from myfile.dat put '... ; emitf @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf > "mytap.dat", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf >> "mytap.dat", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf > stderr, @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf | "grep somepattern", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf | "grep somepattern > mytap.dat", @a, @b, @c' Please see http://johnkerl.org/miller/doc for more information. .fi @@ -2428,6 +2432,17 @@ emitf: inserts non-indexed out-of-stream variable(s) side-by-side into the .nf dump: prints all currently defined out-of-stream variables immediately to stdout as JSON. + + With >, >>, or |, the data do not become part of the output record stream but + are instead redirected. The > and >> are for write and append, as in the + shell, but (as with awk) the file-overwrite for > is on first write, not per + record. The | is for pipe to a process which will process the data. There will + be one subordinate process for each distinct value of the piped-to command. + + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump }' + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump > "mytap.dat"}' + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump >> "mytap.dat"}' + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump | "jq .[]"}' .fi .if n \{\ .RE @@ -2438,6 +2453,8 @@ dump: prints all currently defined out-of-stream variables immediately .nf edump: prints all currently defined out-of-stream variables immediately to stderr as JSON. + + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { edump }' .fi .if n \{\ .RE @@ -2447,8 +2464,9 @@ edump: prints all currently defined out-of-stream variables immediately .\} .nf print: prints expression immediately to stdout. - Example: mlr put -q 'print "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { print k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'print "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { print k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { print > stderr, "Checkpoint ".NR}' .fi .if n \{\ .RE @@ -2458,8 +2476,9 @@ print: prints expression immediately to stdout. .\} .nf print: prints expression immediately to stdout. - Example: mlr put -q 'print "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { print k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'print "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { print k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { print > stderr, "Checkpoint ".NR}' .fi .if n \{\ .RE @@ -2469,8 +2488,9 @@ print: prints expression immediately to stdout. .\} .nf eprint: prints expression immediately to stderr. - Example: mlr put -q 'eprint "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { eprint k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'eprint "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { eprint k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { eprint "Checkpoint ".NR}' .fi .if n \{\ .RE @@ -2480,8 +2500,9 @@ eprint: prints expression immediately to stderr. .\} .nf eprint: prints expression immediately to stderr. - Example: mlr put -q 'eprint "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { eprint k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'eprint "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { eprint k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { eprint "Checkpoint ".NR}' .fi .if n \{\ .RE @@ -2490,8 +2511,8 @@ eprint: prints expression immediately to stderr. .RS 0 .\} .nf -stdout: Used for tee, emit, emitf, emitp, and dump in place of filename to - print to standard output. +stdout: Used for tee, emit, emitf, emitp, print, and dump in place of filename + to print to standard output. .fi .if n \{\ .RE @@ -2500,8 +2521,8 @@ stdout: Used for tee, emit, emitf, emitp, and dump in place of filename to .RS 0 .\} .nf -stderr: Used for tee, emit, emitf, emitp, and dump in place of filename to - print to standard error. +stderr: Used for tee, emit, emitf, emitp, print, and dump in place of filename + to print to standard error. .fi .if n \{\ .RE diff --git a/doc/reference.html b/doc/reference.html index 0205be686..62b6f2d07 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -5272,22 +5272,22 @@ pipeline stage. $ mlr --help-all-keywords filter: includes/excludes the record in the output record stream. - Example: mlr put 'filter (NR == 2 || $x > 5.4)'. + Example: mlr --from myfile.dat put 'filter (NR == 2 || $x > 5.4)' Instead of put with 'filter false' you can simply use put -q. The following uses the input record to accumulate data but only prints the running sum without printing the input record: - Example: mlr put -q '@running_sum += $x * $y; emit @running_sum'. + Example: mlr --from myfile.dat put -q '@running_sum += $x * $y; emit @running_sum' unset: clears field(s) from the current record, or an out-of-stream variable. - Example: mlr put 'unset $x' - Example: mlr put 'unset $*' - Example: mlr put 'for (k, v in $*) { if (k =~ "a.*") { unset $[k] } }' - Example: mlr put '...; unset @sums' - Example: mlr put '...; unset @sums["green"]' - Example: mlr put '...; unset @*' + Example: mlr --from myfile.dat put 'unset $x' + Example: mlr --from myfile.dat put 'unset $*' + Example: mlr --from myfile.dat put 'for (k, v in $*) { if (k =~ "a.*") { unset $[k] } }' + Example: mlr --from myfile.dat put '...; unset @sums' + Example: mlr --from myfile.dat put '...; unset @sums["green"]' + Example: mlr --from myfile.dat put '...; unset @*' tee: prints the current record to specified file. This is an immediate print to the specified file (except for pprint format @@ -5297,10 +5297,11 @@ tee: prints the current record to specified file. process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put 'tee > "/tmp/data-".$a, $*' - Example: mlr put 'tee >> "/tmp/data-".$a.$b, $*' - Example: mlr put -q 'tee | "tr [a-z\] [A-Z\]", $*' - Example: mlr put -q 'tee | "tr [a-z\] [A-Z\] > /tmp/data-".$a, $*' + Example: mlr --from myfile.dat put 'tee > "/tmp/data-".$a, $*' + Example: mlr --from myfile.dat put 'tee >> "/tmp/data-".$a.$b, $*' + Example: mlr --from myfile.dat put 'tee > stderr, $*' + Example: mlr --from myfile.dat put -q 'tee | "tr [a-z\] [A-Z\]", $*' + Example: mlr --from myfile.dat put -q 'tee | "tr [a-z\] [A-Z\] > /tmp/data-".$a, $*' emit: inserts an out-of-stream variable into the output record stream. Hashmap indices present in the data but not slotted by emit arguments are not output. @@ -5311,12 +5312,13 @@ emit: inserts an out-of-stream variable into the output record stream. Hashmap record. The | is for pipe to a process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put '... ; emit @sums' - Example: mlr put '... ; emit @sums, "index1", "index2"' - Example: mlr put '... ; emit @*, "index1", "index2"' - Example: mlr put '... ; emit > "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emit >> "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emit | "grep somepattern", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit @sums' + Example: mlr --from myfile.dat put '... ; emit @sums, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit > "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit >> "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit > stderr, @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emit | "grep somepattern", @*, "index1", "index2"' Please see http://johnkerl.org/miller/doc for more information. @@ -5330,12 +5332,13 @@ emitp: inserts an out-of-stream variable into the output record stream. record. The | is for pipe to a process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put '... ; emitp @sums' - Example: mlr put '... ; emitp @sums, "index1", "index2"' - Example: mlr put '... ; emitp @*, "index1", "index2"' - Example: mlr put '... ; emitp > "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emitp >> "mytap.dat", @*, "index1", "index2"' - Example: mlr put '... ; emitp | "grep somepattern", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp @sums' + Example: mlr --from myfile.dat put '... ; emitp @sums, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp > "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp >> "mytap.dat", @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp > stderr, @*, "index1", "index2"' + Example: mlr --from myfile.dat put '... ; emitp | "grep somepattern", @*, "index1", "index2"' Please see http://johnkerl.org/miller/doc for more information. @@ -5348,40 +5351,56 @@ emitf: inserts non-indexed out-of-stream variable(s) side-by-side into the record. The | is for pipe to a process which will process the data. There will be one subordinate process for each distinct value of the piped-to command. - Example: mlr put '... ; emitf @a' - Example: mlr put '... ; emitf @a, @b, @c' - Example: mlr put '... ; emitf > "mytap.dat", @a, @b, @c' - Example: mlr put '... ; emitf >> "mytap.dat", @a, @b, @c' - Example: mlr put '... ; emitf | "grep somepattern", @a, @b, @c' - Example: mlr put '... ; emitf | "grep somepattern > mytap.dat", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf @a' + Example: mlr --from myfile.dat put '... ; emitf @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf > "mytap.dat", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf >> "mytap.dat", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf > stderr, @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf | "grep somepattern", @a, @b, @c' + Example: mlr --from myfile.dat put '... ; emitf | "grep somepattern > mytap.dat", @a, @b, @c' Please see http://johnkerl.org/miller/doc for more information. dump: prints all currently defined out-of-stream variables immediately to stdout as JSON. + With >, >>, or |, the data do not become part of the output record stream but + are instead redirected. The > and >> are for write and append, as in the + shell, but (as with awk) the file-overwrite for > is on first write, not per + record. The | is for pipe to a process which will process the data. There will + be one subordinate process for each distinct value of the piped-to command. + + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump }' + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump > "mytap.dat"}' + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump >> "mytap.dat"}' + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { dump | "jq .[]"}' + edump: prints all currently defined out-of-stream variables immediately to stderr as JSON. + Example: mlr --from myfile.dat put -q '@v[NR]=$*; end { edump }' + print: prints expression immediately to stdout. - Example: mlr put -q 'print "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { print k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'print "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { print k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { print > stderr, "Checkpoint ".NR}' printn: prints expression immediately to stdout, without trailing newline. - Example: mlr put -q 'printn "The sum of x and y is ".($x+$y); print ""'. + Example: mlr --from myfile.dat put -q 'printn "."; end { print "" }' eprint: prints expression immediately to stderr. - Example: mlr put -q 'eprint "The sum of x and y is ".($x+$y)'. - Example: mlr put -q 'for (k, v in $*) { eprint k . " => " . v }'. + Example: mlr --from myfile.dat put -q 'eprint "The sum of x and y is ".($x+$y)' + Example: mlr --from myfile.dat put -q 'for (k, v in $*) { eprint k . " => " . v }' + Example: mlr --from myfile.dat put '(NR % 1000 == 0) { eprint "Checkpoint ".NR}' eprintn: prints expression immediately to stderr, without trailing newline. - Example: mlr put -q 'eprintn "The sum of x and y is ".($x+$y)'; eprint "". + Example: mlr --from myfile.dat put -q 'eprintn "The sum of x and y is ".($x+$y)'; eprint "" -stdout: Used for tee, emit, emitf, emitp, and dump in place of filename to - print to standard output. +stdout: Used for tee, emit, emitf, emitp, print, and dump in place of filename + to print to standard output. -stderr: Used for tee, emit, emitf, emitp, and dump in place of filename to - print to standard error. +stderr: Used for tee, emit, emitf, emitp, print, and dump in place of filename + to print to standard error.