cdxdoc

uniq : Select only one of any set of equivilent adjacent lines.

USAGE : cdx uniq [options…] [file]

Command Line Options

     
-k –key Spec How to compare adjacent lines. Spec is any of the standard Comparisons
-c –count=ColName,Position Add count of matched lines. See below.
-w –which=Pos,Comp Which of the matching lines is displayed? See below.
-a –agg=Spec Merge values from this column, in place. See below.
  –agg-pre Merge values from this column, into new column. See below.
  –agg-post Merge values from this column, into new column. See below.
  –agg-help Print help for Aggregators

If any adjacent lines compare equal, only the first is printed.

Count

Count takes a two part, comma delimited parameter. The first part is th new column name, which defaults to ‘count’. The second part is ‘begin’ or ‘end’, saying that th new column should either be first or last in the output file. The defaul is ‘begin’, so -c , will produce a new first column named ‘count’, and --count Num,End will produce a new final column named ‘Num’.

Which

When several line are equal (according to --key) which line is printed?

Aggregators

Sometimes you don’t want to select one representitive line, but rather you need tom aggregate the values from the input column values into a new column value. There are three ways to specify aggregation

Details

There can be many different Comparators in opertion at the same time. For example

cdx uniq --key title,lower --which Max,price,float --agg year,max,numeric

The lines of the file are compared by the case-insensitve text of the title field. Among those lines with matching titles, the line with the highest price is selected, except that the output year column will be the latest year mentioned.

home