The wc utility is a Python3 implementation that mimics the Unix wc command. It counts newlines, words, characters, and bytes in files and standard input, providing users with essential text processing capabilities.
- Python 3.x
python wc.py [options] [file ...]-l: Count lines-w: Count words-c: Count bytes-m: Count characters
python wc.py -l test.txt # Count lines in test.txt
python wc.py -w test.txt # Count words in test.txt
python wc.py -c test.txt # Count bytes in test.txtecho "Hello World" | python wc.py -w # Count words from stdin
cat test.txt | python wc.py -l # Count lines from stdinThe default output format is tab-separated values showing counts for lines, words, characters, and bytes.
- The line count uses
len(line)on bytes lines. - Word counting uses
splitto determine word boundaries. - When using stdin mode with no arguments, the utility will print 'not enough args'.
The repository includes test.txt as a sample file to test the utility's features.