Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
    
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 1 at 14:28
    
Possibly relevant: stackoverflow.com/questions/10546337/… Maybe -t was a Debian-specific option that was later removed? –  Martin von Wittich Feb 1 at 14:31
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 1 at 15:57

2 Answers 2

up vote 13 down vote accepted

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.

share|improve this answer
    
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 1 at 15:02
    
@Graeme Good point, edited. –  casey Feb 1 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 2 at 0:07

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.