We’re going to write a Python version of the venerable wc
(“word count”) program. Ours will be called wc.py, and it will count the lines, words, and bytes found in each input supplied as one or more positional arguments. The counts will appear in columns eight characters wide, and they will be followed by the name of the file. For instance, here is what wc.py should print for one file:
$ ./wc.py ../inputs/scarlet.txt 7035 68061 396320 ../inputs/scarlet.txt
$ ./wc.py ../inputs/const.txt ../inputs/sonnet-29.txt 865 7620 44841 ../inputs/const.txt 17 118 661 ../inputs/sonnet-29.txt 882 7738 45502 total