%%s 0/0/0 %%d D 1.1 25-Mar-82 12:16:15 v1.1 1 0 %%c Version 1.1 is the Spring 1982 Distribution of the LBL/Hughes release %%c of the Software Tools Virtual Operating System software and documentation. %%T %%I 1 #-h- uniq.r 1450 asc 25-mar-82 09:03:17 v1.1 (sw-tools v1.1) #-h- main 618 asc 25-mar-82 09:02:54 v1.1 (sw-tools v1.1) ## uniq -strip adjacent duplicate lines DRIVER(uniq) character buf(MAXLINE) integer open, getarg integer i, int, count data count /NO/ call query("usage: uniq [-c] [file] ...") for (i=1; getarg(i, buf, MAXLINE) != EOF; i=i+1) { if (buf(1) == '-' & (buf(2) == 'c' | buf(2) == 'C')) { count = YES next } else if (buf(1) == '-' & buf(2) == EOS) int = STDIN else { int = open(buf,READ) if (int == ERR) call cant(buf) } call unique (int, count) if (int != STDIN) call close(int) } if (i == 1 | (i == 2 & count == YES)) #read from STDIN call unique (STDIN, count) DRETURN end #-h- unique 686 asc 25-mar-82 09:02:57 v1.1 (sw-tools v1.1) ## unique - locate duplicate lines in file int subroutine unique (int, count) integer equal, getlin integer t, count, k character buf1(MAXLINE), buf2(MAXLINE) t = getlin(buf1, int) while (t != EOF) { k = 1 for (t=getlin(buf2,int); t!= EOF; t=getlin(buf2,int)) { if (equal(buf1, buf2) == NO) break k = k + 1 } if (count == YES) { call putdec(k, 5) call putc(' ') } call putlin(buf1, STDOUT) if (t == EOF) break k = 1 for (t=getlin(buf1,int); t!= EOF; t=getlin(buf1,int)) { if (equal(buf1,buf2) == NO) break k = k + 1 } if (count == YES) { call putdec(k, 5) call putc(' ') } call putlin(buf2, STDOUT) } return end #-h- uniq.fmt 619 asc 25-mar-82 09:03:19 v1.1 (sw-tools v1.1) .so ~bin/manhdr .hd Uniq (1) 11-Jan-79 strip adjacent repeated lines from a file .sy uniq [-c] [file] ... .ds uniq reads the input file(s), comparing adjacent lines. Second and succeeding copies of repeated lines are removed; the remainder is written to standard output. If the '-c' flag is given, each line is preceded by a count of the number of occurrences of that line. .fl .sa The tool 'comm'; the Unix command 'uniq' .di A message is printed if an input file cannot be opened and processing is terminated. .au Originally from Kernighan and Plauger's 'Software Tools', with modifications by Debbie Scherrer. .bu %%E 1