Skip to content

rajatsing/ccwc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ccwc is a command-line utility written in Go for analyzing text files. It calculates the number of bytes, lines, words, and characters in a file or from standard input. Inspired by Unix tools like wc, it provides flexible options for text analysis. Features

  • Count bytes, lines, words, or characters in a file.
  • Supports input via file paths or piped input.
  • Simple and intuitive flags for specific operations. Installation
  1. Clone the repository:
git clone https://github.com/rajatsing/ccwc.git
cd ccwc
  1. Build the binary:
go build -o ccwc
  1. (Optional) Add it to your PATH for global use:
mv ccwc /usr/local/bin/

Usage

Analyze a File

  • Count bytes:
ccwc -c filename.txt
  • Count lines:
ccwc -l filename.txt
  • Count words:
ccwc -w filename.txt
  • Count characters:
ccwc -m filename.txt

Analyze Piped Input

  • Count lines in piped input:
cat filename.txt | ccwc -l
  • Count words in piped input:
echo "This is a test" | ccwc -w

Default Output

If no flags are specified, the default output includes all metrics:

ccwc filename.txt

Example output:

342190 7145 5200

(Output format: bytes lines words) Flags

Flag Shorthand Description
--bytes -c Number of bytes in the file
--lines -l Number of lines in the file
--words -w Number of words in the file
--chars -m Number of characters in the file
Examples
  • Count lines in a file:
ccwc -l sample.txt
  • Count words from a piped input:
echo "Hello world!" | ccwc -w

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages