repositorypackage
0.0.0-20241031222658-b9c88e9fb387
Repository: https://github.com/wahlly/wc-tool.git
Documentation: pkg.go.dev
# README
WC-tool
A command-line utility tool written in Go that provides word count functionalities similar to the Unix wc
command. This tool can count words, lines, characters, and bytes in a given file or text input, and supports multiple command options for customized output.
Setup
- Clone the repository
git clone https://github.com/wahlly/WC-tool.git cd WC-tool
- Ensure you have Golang installed, then build the project by running
go build -o wc
- Run the project(from the root directory)
go run .
Usage
The wc tool can be executed with various options, each with its use. here is a list of all available options:
Command Options
The following commands are available:
- -w : Outputs the number of words in the file
- -l : Outputs the number of lines in the file
- -c : Outputs the number of bytes in the file
- -m : Outputs the number of characters in the file
Examples
- Character count
ccwc -c test.txt
- Line count
ccwc -l test.txt
- Word count
ccwc -w test.txt
- Character count
ccwc -m test.txt wc -m test.txt
The default option i.e. when no options are provided, is equivalent to -c, -l and -w options.
ccwc test.txt
It is also possible to read from standard input, if no file is specified. An example is shown below. This reads the test.txt
file in the stdin and then outputs the number of lines in it
cat test.txt | ccwc -l