A Python-based implementation of the Unix wc command that provides file analysis capabilities including byte count, line count, word count, and character count.
- Count bytes in a file (
-c) - Count lines in a file (
-l) - Count words in a file (
-w) - Count characters in a file (
-m) - Display all counts together (default behavior)
- Support for both file input and piped input
git clone https://github.com/hard02/hkwc
cd hkwcpython hkwc_build/main.py [operation] [file]c- Count bytesl- Count linesw- Count wordsm- Count charactersall- Show lines, words, and bytes (default)
Count all metrics in a file:
python hkwc_build/main.py test.txtCount only lines:
python hkwc_build/main.py l test.txtUse with piped input:
cat test.txt | python hkwc_build/main.py wThe output format varies based on the operation:
- Single operation:
[count] [filename] - All operations:
[lines] [words] [bytes] [filename]
The script includes execution time measurement, displayed after each operation.
- Python 3.6 or higher
- No additional dependencies required
The script includes robust error handling for:
- File not found
- Permission issues
- Invalid file formats
- Invalid inputs
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
Feel free to submit issues and enhancement requests!