summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete <pete@debu.gs>2023-11-02 10:48:39 -0700
committerPete <pete@debu.gs>2024-04-16 17:53:16 -0700
commit66262a3ff477139b49b651996943d9a8bd2cb31e (patch)
tree0c7223fa160828a8027e31530d6e93ac019fcf1a
parent54b1df79e786e6e814d581a73354fc955a33793e (diff)
Add -c to uniq.
(Match Plan 9.)
-rw-r--r--appl/cmd/uniq.b15
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();
}