-.\" $OpenBSD: uniq.1,v 1.19 2016/10/24 13:46:58 schwarze Exp $
+.\" $OpenBSD: uniq.1,v 1.20 2017/12/21 10:05:59 tb Exp $
.\" $NetBSD: uniq.1,v 1.5 1994/12/06 07:51:15 jtc Exp $
.\"
.\" Copyright (c) 1991, 1993
.\"
.\" @(#)uniq.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd $Mdocdate: October 24 2016 $
+.Dd $Mdocdate: December 21 2017 $
.Dt UNIQ 1
.Os
.Sh NAME
.Nd report or filter out repeated lines in a file
.Sh SYNOPSIS
.Nm uniq
-.Op Fl c
+.Op Fl ci
.Op Fl d | u
.Op Fl f Ar fields
.Op Fl s Ar chars
A field is a string of non-blank characters separated from adjacent fields
by blanks, with blanks considered part of the following field.
Field numbers are one based, i.e., the first field is field one.
+.It Fl i
+Case insensitive comparison of lines.
.It Fl s Ar chars
Ignore the first
.Ar chars
.St -p1003.1-2008
specification.
.Pp
-The use of
+The
+.Fl i
+option and the use of
.Fl c
in conjunction with
.Fl d
or
.Fl u
-is an extension to that specification.
+are extensions to that specification.
.Pp
The historic
.Cm + Ns Ar number
-/* $OpenBSD: uniq.c,v 1.24 2015/12/19 10:21:01 schwarze Exp $ */
+/* $OpenBSD: uniq.c,v 1.25 2017/12/21 10:05:59 tb Exp $ */
/* $NetBSD: uniq.c,v 1.7 1995/08/31 22:03:48 jtc Exp $ */
/*
#define MAXLINELEN (8 * 1024)
-int cflag, dflag, uflag;
+int cflag, dflag, iflag, uflag;
int numchars, numfields, repeats;
FILE *file(char *, char *);
err(1, "pledge");
obsolete(argv);
- while ((ch = getopt(argc, argv, "cdf:s:u")) != -1) {
+ while ((ch = getopt(argc, argv, "cdf:is:u")) != -1) {
const char *errstr;
switch (ch) {
errx(1, "field skip value is %s: %s",
errstr, optarg);
break;
+ case 'i':
+ iflag = 1;
+ break;
case 's':
numchars = (int)strtonum(optarg, 0, INT_MAX,
&errstr);
}
/* If different, print; set previous to new value. */
- if (strcmp(t1, t2)) {
+ if ((!iflag && strcmp(t1, t2)) || strcasecmp(t1, t2)) {
show(ofp, prevline);
t1 = prevline;
prevline = thisline;
extern char *__progname;
(void)fprintf(stderr,
- "usage: %s [-c] [-d | -u] [-f fields] [-s chars] [input_file [output_file]]\n",
+ "usage: %s [-ci] [-d | -u] [-f fields] [-s chars] [input_file [output_file]]\n",
__progname);
exit(1);
}