wc is a command-line tool written in Go for counting lines, words, characters, and bytes in text files. It replicates and extends the functionality of the Unix wc utility, offering enhanced features like comparison mode and custom flag options.
- Line Counting: Counts the number of lines in a file.
- Word Counting: Counts the number of words in a file.
- Byte Counting: Counts the number of bytes in a file.
- Character Counting: Counts the number of characters in a file.
- Compare Mode: Provides an additional pass to compare different counting methods.
- File or Standard Input Support: Accepts both file paths and standard input.
- Clone the repository:
git clone https://github.com/omarahr/ccwc.git cd ccwc - Build the binary:
go build -o ccwc main.go
The tool provides several flags to control the counting functionality:
wc [flags] [file...]-c, --count bytes: Count bytes.-l, --count lines: Count lines.-w, --count words: Count words.-m, --count chars: Count characters.-s, --compare mode: Enable comparison mode for additional validation.
-
Count lines, words, and bytes in a file:
./ccwc -l -w -c example.txt
-
Use standard input:
echo "Hello world" | ./ccwc -w
-
Compare counting methods for a file:
./ccwc -s example.txt
This project is licensed under the MIT License.
- Inspired the solution from Coding Challenges by John Crickett