summaryrefslogtreecommitdiff
path: root/appl/cmd
diff options
context:
space:
mode:
authorCharles Forsyth <charles.forsyth@gmail.com>2024-04-22 06:59:12 +0100
committerGitHub <noreply@github.com>2024-04-22 06:59:12 +0100
commit3461be9f61d07b89d9e41f771f7bcdff2e0ba0b6 (patch)
treecb954a79dc249e850fe0636458e1b47e873d23ca /appl/cmd
parent54b1df79e786e6e814d581a73354fc955a33793e (diff)
parent68b5462cb24decbfc1baac0c323201dec655d850 (diff)
Merge pull request #15 from pete/add-uniq-c
Add uniq -c
Diffstat (limited to 'appl/cmd')
-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();
}