summaryrefslogtreecommitdiffstats
path: root/contrib/awk/awklib/eg/prog/wc.awk
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/awk/awklib/eg/prog/wc.awk')
-rw-r--r--contrib/awk/awklib/eg/prog/wc.awk69
1 files changed, 0 insertions, 69 deletions
diff --git a/contrib/awk/awklib/eg/prog/wc.awk b/contrib/awk/awklib/eg/prog/wc.awk
deleted file mode 100644
index f46616b..0000000
--- a/contrib/awk/awklib/eg/prog/wc.awk
+++ /dev/null
@@ -1,69 +0,0 @@
-# wc.awk --- count lines, words, characters
-#
-# Arnold Robbins, arnold@gnu.org, Public Domain
-# May 1993
-
-# Options:
-# -l only count lines
-# -w only count words
-# -c only count characters
-#
-# Default is to count lines, words, characters
-#
-# Requires getopt and file transition library functions
-
-BEGIN {
- # let getopt print a message about
- # invalid options. we ignore them
- while ((c = getopt(ARGC, ARGV, "lwc")) != -1) {
- if (c == "l")
- do_lines = 1
- else if (c == "w")
- do_words = 1
- else if (c == "c")
- do_chars = 1
- }
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
-
- # if no options, do all
- if (! do_lines && ! do_words && ! do_chars)
- do_lines = do_words = do_chars = 1
-
- print_total = (ARGC - i > 2)
-}
-function beginfile(file)
-{
- chars = lines = words = 0
- fname = FILENAME
-}
-function endfile(file)
-{
- tchars += chars
- tlines += lines
- twords += words
- if (do_lines)
- printf "\t%d", lines
- if (do_words)
- printf "\t%d", words
- if (do_chars)
- printf "\t%d", chars
- printf "\t%s\n", fname
-}
-# do per line
-{
- chars += length($0) + 1 # get newline
- lines++
- words += NF
-}
-END {
- if (print_total) {
- if (do_lines)
- printf "\t%d", tlines
- if (do_words)
- printf "\t%d", twords
- if (do_chars)
- printf "\t%d", tchars
- print "\ttotal"
- }
-}
OpenPOWER on IntegriCloud