From 1fd4762a41cf84d9b6ebe9ed4dcf83cde78f61d3 Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Sun, 17 Mar 2019 13:29:19 +0100 Subject: toks-per-line: count --- toks-per-line | 9 +++++++-- 1 file 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 -- cgit v1.2.3