15

I have some old code from 2003 which uses -t option for uniq command. It throws an error since that option is probably not supported anymore.

Here's the piece which uses the command:

egrep -n "{ IA32_OP" ia32-decode.c | \
    awk '{ print $1 $3 $4 }' | \
    sort -t '(' +1 | \
    uniq -t ':' -f 1 | \
    sed 's/\(.*\)\:IA32_OP(\(.*\)),/#define IA32_OP_\2 \1/g' >> ia32_opcodes.h

What did that option do back then? What can I substitute that command with?

  • Here's the source BTW: https://web.archive.org/web/20040217131820/http://www.team-teso.net/projects/objobf/objobf-0.5.0.tar.bz2 – Babken Vardanyan Feb 01 '14 at 14:01
  • According to man uniq, -f 1 avoids comparing the first field. I'd infer from -t ':' that -t is supposed to change the field seperator from blanks to :. – Martin von Wittich Feb 01 '14 at 14:28
  • Possibly relevant: http://stackoverflow.com/questions/10546337/uniq-command-how-to-get-delimiter-option-and-search-on-the-basis-of-column Maybe -t was a Debian-specific option that was later removed? – Martin von Wittich Feb 01 '14 at 14:31
  • 1
    Possibly relevant: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=117016 – Martin von Wittich Feb 01 '14 at 14:32
  • 1
    I always wondered why uniq didn't have the same -t and -k as sort or why sort didn't have all the features of uniq incorporated (since it now has -u). Those -w/-f/-s from GNU uniq don't make sense. Why couldn't they use the same syntax as sort. – Stéphane Chazelas Feb 01 '14 at 15:57
  • The Debian changelog records the loss of this feature under the heading "Remove some ancient debian-specific patches" in version 5.93-1 –  Feb 01 '14 at 16:12
  • See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=31106 which was fixed by adding that -t in textutils 2.0-3 in Debian woody – Stéphane Chazelas Feb 01 '14 at 16:12

2 Answers2

13

The only reference I could find to -t is in this patch on a GNU mailing list, which contains among other clues, this:

+  -t, --separator=S     use a character in string S as field separator\n\

This apparently was a GNU extension but no longer in use. It appears to allow selecting a delimiting character for fields other than spaces or tabs. Try replacing

uniq -t ':' -f 1 | \

with

sed 's/:/ /' | \
uniq -f 1 | \

which will replace : with spaces which uniq recognizes the field separator.

casey
  • 14,754
  • I would drop the g from sed, since only the first field is skipped. At least one colon is needed for the last line to work (hopefully not the first). Still no guarantee it will work though (any of the first fields may contain whitespace) – Graeme Feb 01 '14 at 15:02
  • @Graeme Good point, edited. – casey Feb 01 '14 at 15:23
  • In Debian, coreutils 5.2.1 indeed had such a patch applied, and apparently it was removed in 5.93-1, that is, in November 2005. – user2719058 Feb 02 '14 at 00:07
4

Given the man entry for the -f option:

-f, --skip-fields=N

         avoid comparing the first N fields

I think it is fairly safe to assume that -t specifies the field separator (this is also the case for sort in the line above). The combination of the two options would make uniq only operate on the part of the line following the first colon.

Graeme
  • 34,027