diff options
Diffstat (limited to 'appl')
| -rw-r--r-- | appl/cmd/uniq.b | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/appl/cmd/uniq.b b/appl/cmd/uniq.b index 4442c22f..9846e69f 100644 --- a/appl/cmd/uniq.b +++ b/appl/cmd/uniq.b @@ -13,7 +13,7 @@ Uniq: module usage() { - fail("usage", sys->sprint("usage: uniq [-ud] [file]")); + fail("usage", sys->sprint("usage: uniq [-udc] [file]")); } init(nil : ref Draw->Context, args : list of string) @@ -31,6 +31,7 @@ init(nil : ref Draw->Context, args : list of string) uflag := 0; dflag := 0; + cflag := 0; arg->init(args); while ((opt := arg->opt()) != 0) { case opt { @@ -38,6 +39,8 @@ init(nil : ref Draw->Context, args : list of string) uflag = 1; 'd' => dflag = 1; + 'c' => + cflag = 1; * => usage(); } @@ -61,14 +64,20 @@ init(nil : ref Draw->Context, args : list of string) if (s == prev) n++; else { - if ((uflag && n == 1) || (dflag && n > 1)) + if ((uflag && n == 1) || (dflag && n > 1)) { + if(cflag) + prev = string n + "\t" + prev; stdout.puts(prev); + } n = 1; prev = s; } } - if ((uflag && n == 1) || (dflag && n > 1)) + if ((uflag && n == 1) || (dflag && n > 1)) { + if(cflag) + prev = string n + "\t" + prev; stdout.puts(prev); + } stdout.close(); } |
