diff --git i/NEWS w/NEWS index d97a9a4..b30e91d 100644 --- i/NEWS +++ w/NEWS @@ -16,6 +16,10 @@ either as IPv4-Mapped (ipv6v4map) or IPv4-Compatible (ipv6v4comp) addresses. + Add two command aliases: + 'echo' may now be used instead of 'cut'. + 'uniq' may now be used instead of 'unique'. + ** Improvements Updated the bash completion script to reflect recent additions. diff --git i/contrib/bash-completion/datamash w/contrib/bash-completion/datamash index 9a62df9..86b467d 100644 --- i/contrib/bash-completion/datamash +++ w/contrib/bash-completion/datamash @@ -26,7 +26,7 @@ _datamash () # or the regex will fail. local groupby_ops="sum min max absmin absmax range \ count first last rand \ -unique collapse countunique \ +unique uniq collapse countunique \ mean geomean harmmean trimmean median q1 q3 iqr perc mode antimode \ pstdev sstdev pvar svar mad madraw \ pskew sskew pkurt skurt dpo jarque \ @@ -35,7 +35,7 @@ pcov scov ppearson spearson" local line_ops="base64 debase64 md5 sha1 sha224 sha256 sha384 sha512 \ round floor ceil trunc frac bin strbin dirname basename extname barename \ -getnum cut" +getnum cut echo" local line_ops_re=${line_ops// /|} local datamash_short_options="-c -C -f -g -H -i -s -t -R -W -z" diff --git i/doc/datamash.texi w/doc/datamash.texi index cb90b1c..ac02749 100644 --- i/doc/datamash.texi +++ w/doc/datamash.texi @@ -177,13 +177,14 @@ thousands separator. @code{sha224}, @code{sha256}, @code{sha384}, @code{sha512}, @code{bin}, @code{strbin}, @code{round}, @code{floor}, @code{ceil}, @code{trunc}, @code{frac}, @code{dirname}, @code{basename}, @code{extname}, @code{barename}, -@code{getnum}, @code{cut} +@code{getnum}, @code{cut}, @code{echo} @item Group-by Numeric operations: @code{sum}, @code{min}, @code{max}, @code{absmin}, @code{absmax}, @code{range} @item Group-by Textual/Numeric operations: -@code{count}, @code{first}, @code{last}, @code{rand}, @code{unique}, +@code{count}, @code{first}, @code{last}, @code{rand}, +@code{unique}, @code{uniq}, @code{collapse}, @code{countunique} @item Group-by Statistical operations: @@ -249,7 +250,8 @@ file has a header line, and the output should contain a header line as well. @opindex --ignore-case @opindex -i Ignore upper/lower case when comparing text for grouping, sorting, and comparing -unique values in the @samp{countunique} and @samp{unique} operations. +unique values in the @samp{countunique} and @samp{unique} +(or @samp{uniq}) operations. @item --sort @itemx -s @@ -324,7 +326,7 @@ This option overrides @option{--field-separator}/@option{-t}/ @opindex -c Use character @var{X} instead of comma to delimit items in a -@samp{collapse} or @samp{unique} list. +@samp{collapse} or @samp{unique} (aka @samp{uniq}) list. @item --round=@var{N} @itemx -R @var{N} @@ -429,6 +431,8 @@ extract a number from the field. @code{getnum} accepts an optional single letter option @samp{n/i/d/p/h/o} affecting the detected value. @item cut copy input field to output field (similar to @command{cut(1)}). +@item echo +an alias for @code{cut}. @end table @item Group-by Numeric operations: @@ -465,6 +469,8 @@ the last value of the group one random value from the group @item unique comma-separated sorted list of unique values +@item uniq +an alias for @code{unique}. @option{--collapse-delimiter} can be used to use a different character than comma. diff --git i/man/datamash.x w/man/datamash.x index 5f5ebe8..3347b57 100644 --- i/man/datamash.x +++ w/man/datamash.x @@ -101,8 +101,9 @@ extract a number from the field. \fBTYPE\fR is optional single letter option n/i/d/p/h/o (see examples below). .TP -.B cut +.B cut/echo copy input field to output field (similar to cut(1)). +The echo command is simply an alias to cut. .PP @@ -152,8 +153,9 @@ the last value of the group one random value from the group .TP -.B unique +.B unique/uniq comma-separated sorted list of unique values +The uniq command is simply an alias to unique. .TP .B collapse diff --git i/src/op-defs.c w/src/op-defs.c index cabe2d1..11e62b5 100644 --- i/src/op-defs.c +++ w/src/op-defs.c @@ -70,6 +70,7 @@ struct field_operation_definition field_operations[] = {"mode", OP_MODE, MODE_GROUPBY}, {"antimode",OP_ANTIMODE,MODE_GROUPBY}, {"unique", OP_UNIQUE, MODE_GROUPBY}, + {"uniq", OP_UNIQUE, MODE_GROUPBY}, {"collapse",OP_COLLAPSE,MODE_GROUPBY}, {"countunique", OP_COUNT_UNIQUE, MODE_GROUPBY}, {"base64", OP_BASE64, MODE_PER_LINE}, @@ -98,6 +99,7 @@ struct field_operation_definition field_operations[] = {"trimmean",OP_TRIMMED_MEAN, MODE_GROUPBY}, {"getnum", OP_GETNUM, MODE_PER_LINE}, {"cut", OP_CUT, MODE_PER_LINE}, + {"echo", OP_CUT, MODE_PER_LINE}, {NULL, OP_INVALID, MODE_INVALID} }; diff --git i/tests/datamash-tests-2.pl w/tests/datamash-tests-2.pl index 4356fa3..d743244 100755 --- i/tests/datamash-tests-2.pl +++ w/tests/datamash-tests-2.pl @@ -653,6 +653,15 @@ my @Tests = ['cut1','-t, cut 3,1,2', {IN_PIPE=>$in1_cut}, {OUT=>"c,a,b\n6,1,X\n"}], ['cut2','-t, -H cut c,a', {IN_PIPE=>$in1_cut}, {OUT=>"cut(c),cut(a)\n6,1\n"}], + # Aliases (more-or-less: copy-paste above tests and s/orig/alias/ the command names.) + ['alias1','-t, echo 3,1,2', {IN_PIPE=>$in1_cut}, {OUT=>"c,a,b\n6,1,X\n"}], + ['alias2','-t, -H echo c,a', {IN_PIPE=>$in1_cut}, {OUT=>"cut(c),cut(a)\n6,1\n"}], + ['alias3', '-t: --narm uniq 2', {IN_PIPE=>$na_mid1}, + {OUT=>"2,8\n"}], + ['alias4', '-t: uniq 2', {IN_PIPE=>$na_mid1}, + {OUT=>"2,8,NA\n"}], + ['alias5', '--narm uniq 1', {IN_PIPE=>$na_all}, {OUT=>"\n"}], + );