Skip to content

Patacode/ccwc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CC WC

Simplified clone of the wc Unix command line tool.

  • man wc
  • info '(coreutils) wc invocation'

Installation

make build # compile project (create executable ./ccwc)
make test # run unit tests
make report # generate unit tests coverage report

You can benchmark the script by using the benchmark target, which will compare the runtimes of native wc and this utility:

make benchmark

It relies on hyperfine and python scripts. As a pre-requisites, you will need below python dependencies installed:

pip install numpy matplotlib scipy

Usage

Available options:

$ ./ccwc --help

# sample output
Usage: ccwc [OPTION...] [FILENAME]
A simplified clone of wc.

  -c, --bytes                print the byte counts
  -l, --lines                print the newline counts
  -m, --chars                print the character counts
  -w, --words                print the word counts
  -?, --help                 Give this help list
      --usage                Give a short usage message
  -V, --version              Print program version

Report bugs to <maxou.info@gmail.com>.

Count number of bytes in given file:

$ ./ccwc -c data/test.txt

# sample output
342190 data/test.txt

Count number of lines in given file:

$ ./ccwc -l data/test.txt

# sample output
7145 data/test.txt

Count number of chars in given file:

$ ./ccwc -m data/test.txt

# sample output
339292 data/test.txt

Count number of words in given file:

$ ./ccwc -w data/test.txt

# sample output
58164 data/test.txt

You can combine multiple count flags:

$ ./ccwc -wlm data/test.txt

# sample output
7145 58164 339292 data/test.txt

When multiple count flags are provided, the print order will always be lines, words, chars and then bytes count.

If no count flags are given, default to lines, words and bytes count:

$ ./ccwc data/test.txt

# sample output
7145 58164 342190 data/test.txt

If no file is given, default to stdin:

$ cat data/test.txt | ./ccwc

# sample output
7145 58164 342190

Releases

No releases published

Packages

 
 
 

Contributors