diff options
author | Joerg Wunsch <joerg@FreeBSD.org> | 1997-09-07 15:09:22 +0000 |
---|---|---|
committer | Joerg Wunsch <joerg@FreeBSD.org> | 1997-09-07 15:09:22 +0000 |
commit | 2ca7dc15981dfdbcb577b1d6c9733dc2ba6745ff (patch) | |
tree | 9abd770c9f0b021316bef5de99ed15494786ce75 /usr.bin/uniq | |
parent | c816cfc962a2939068bbff235dbc5a3142071c11 (diff) | |
download | src-test2-2ca7dc15981dfdbcb577b1d6c9733dc2ba6745ff.tar.gz src-test2-2ca7dc15981dfdbcb577b1d6c9733dc2ba6745ff.zip |
Notes
Diffstat (limited to 'usr.bin/uniq')
-rw-r--r-- | usr.bin/uniq/uniq.1 | 6 | ||||
-rw-r--r-- | usr.bin/uniq/uniq.c | 17 |
2 files changed, 18 insertions, 5 deletions
diff --git a/usr.bin/uniq/uniq.1 b/usr.bin/uniq/uniq.1 index eb28ca52957d..9ace8541bac3 100644 --- a/usr.bin/uniq/uniq.1 +++ b/usr.bin/uniq/uniq.1 @@ -32,7 +32,8 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)uniq.1 8.1 (Berkeley) 6/6/93 +.\" From: @(#)uniq.1 8.1 (Berkeley) 6/6/93 +.\" $Id$ .\" .Dd June 6, 1993 .Dt UNIQ 1 @@ -43,6 +44,7 @@ .Sh SYNOPSIS .Nm .Op Fl c | Fl d | Fl u +.Op Fl i .Op Fl f Ar fields .Op Fl s Ar chars .Oo @@ -87,6 +89,8 @@ fields will be ignored. Character numbers are one based, i.e. the first character is character one. .It Fl u Don't output lines that are repeated in the input. +.It Fl i +Case insensitive comparison of lines. .\".It Fl Ns Ar n .\"(Deprecated; replaced by .\".Fl f ) . diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c index 972581f54cb9..8f302ca349d8 100644 --- a/usr.bin/uniq/uniq.c +++ b/usr.bin/uniq/uniq.c @@ -45,7 +45,7 @@ static const char copyright[] = static char sccsid[] = "@(#)uniq.c 8.3 (Berkeley) 5/4/95"; #endif static const char rcsid[] = - "$Id$"; + "$Id: uniq.c,v 1.3 1997/08/21 06:51:10 charnier Exp $"; #endif /* not lint */ #include <ctype.h> @@ -75,9 +75,10 @@ main (argc, argv) FILE *ifp, *ofp; int ch; char *prevline, *thisline, *p; + int iflag = 0, comp; obsolete(argv); - while ((ch = getopt(argc, argv, "-cdf:s:u")) != -1) + while ((ch = getopt(argc, argv, "-cdif:s:u")) != -1) switch (ch) { case '-': --optind; @@ -88,6 +89,9 @@ main (argc, argv) case 'd': dflag = 1; break; + case 'i': + iflag = 1; + break; case 'f': numfields = strtol(optarg, &p, 10); if (numfields < 0 || *p) @@ -152,7 +156,12 @@ done: argc -= optind; } /* If different, print; set previous to new value. */ - if (strcmp(t1, t2)) { + if (iflag) + comp = strcasecmp(t1, t2); + else + comp = strcmp(t1, t2); + + if (comp) { show(ofp, prevline); t1 = prevline; prevline = thisline; @@ -245,6 +254,6 @@ static void usage() { (void)fprintf(stderr, - "usage: uniq [-c | -du] [-f fields] [-s chars] [input [output]]\n"); + "usage: uniq [-c | -du | -i] [-f fields] [-s chars] [input [output]]\n"); exit(1); } |