wc is a Unix utility tool that prints the number of lines, words or bytes in a text file. This is a relatively straight forward implementation of the tool in pure C.
You can compile the source file using gcc
(GCC needs to be installed).
mkdir -p ./build
gcc -o ./build/wc ./wc.c
Alternatively, you can batch execute the commands if you have make
installed.
make build
wc expects an optional flag
and filepath
argument.
./build/wc [-FLAG] [FILEPATH]
Example
./build/wc test.txt
7145 58164 342190 test.txt
Example:
./build/wc -c test.txt
342190 test.txt
Example:
./build/wc -l test.txt
7145 test.txt
Example:
./build/wc -w test.txt
58164 test.txt
Example:
./build/wc -m test.txt
339292 test.txt