summaryrefslogtreecommitdiff
path: root/toks-per-line
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2019-03-17 13:29:19 +0100
committerPatrick Simianer <p@simianer.de>2019-03-17 13:29:19 +0100
commit1fd4762a41cf84d9b6ebe9ed4dcf83cde78f61d3 (patch)
treeb870ccd6af8c7d0e4fcaec52dec5fa81fa0fb663 /toks-per-line
parenteedbb76ce84bfbdb3cdb228de094907eb2fd8099 (diff)
toks-per-line: count
Diffstat (limited to 'toks-per-line')
-rwxr-xr-xtoks-per-line9
1 files changed, 7 insertions, 2 deletions
diff --git a/toks-per-line b/toks-per-line
index 012caac..8a10cd4 100755
--- a/toks-per-line
+++ b/toks-per-line
@@ -1,12 +1,17 @@
#!/usr/bin/env ruby
uniq = false
-uniq = true if ARGV[0]
+uniq = true if ARGV.include? "uniq"
+count = true if ARGV.include? "count"
while line = STDIN.gets
a = line.strip.split
a.uniq! if uniq
a.sort!
- puts a.join " "
+ if not count
+ puts a.join " "
+ else
+ puts a.size
+ end
end