wc
ToolThis project involves creating a custom version of the Unix command-line tool wc
. The wc
(word count) command is used to count the number of lines, words, and bytes (or characters) in files. This challenge is to build a simplified version of wc
that supports some basic options.
The tool will read a file and output counts for:
-l
): Counts the number of newline characters in the file.-w
): Counts the number of words in the file. A word is defined as a non-zero-length sequence of characters delimited by whitespace.-m
): Counts the number of characters in the file. For UTF-8 encoded files, this is the number of Unicode characters.-c
): Counts the number of bytes in the file.--help
): Displays usage information and options for the tool.Use the following command:
gcc ccwc.c -o wc
./wc -l test.txt
./wc -w test.txt
./wc -m test.txt
./wc -c test.txt
./wc test.txt
./wc --help
cat test.txt |./wc
Feel free to contribute to this project by submitting pull requests or opening issues for improvements and bug fixes.