Discussion:
uniq feature request: check-fields option
Steve Ward
2009-05-04 05:58:03 UTC
Permalink
For the uniq program, these options exist:

--skip-chars=N
avoid comparing the first N characters

--skip-fields=N
avoid comparing the first N fields

--check-chars=N
compare no more than N characters in lines


It would be nice to have:

--check-fields=N
compare no more than N fields in lines



Steve
Steve Ward
2009-05-07 10:41:03 UTC
Permalink
Post by Steve Ward
--skip-chars=N
avoid comparing the first N characters
--skip-fields=N
avoid comparing the first N fields
--check-chars=N
compare no more than N characters in lines
--check-fields=N
compare no more than N fields in lines
Steve
Here is my use case. I have a sorted file with lines like this:

<unsigned int><tab><string>

I want uniq to print only duplicate lines by comparing the first field, not
the rest of the line.
The integer is not padded, so the first field is never the same number of
characters. (Otherwise I'd use the check-chars option.) The string field
needs to remain intact.


Steve
Pádraig Brady
2009-05-07 11:45:53 UTC
Permalink
Post by Steve Ward
--skip-chars=N
avoid comparing the first N characters
--skip-fields=N
avoid comparing the first N fields
--check-chars=N
compare no more than N characters in lines
--check-fields=N
compare no more than N fields in lines
This was discussed before:
http://lists.gnu.org/archive/html/bug-coreutils/2006-06/msg00168.html
Old versions of Debian did actually have the --check-fields option.
Unfortunately no one has had time to work on the --key alternative.

cheers,
Pádraig.

Loading...