michaelcosj / mwc

mediocre wc (the unix command) clone

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mediocre Word Count (mwc)

A simple word count clone in golang. This is my solution of this coding challenge. Feedback and stuff is appreciated 😘

Running

Make sure you have golang installed

# build the program
go build -o bin/mwc main.go
# running
# ./bin/mwc [OPTIONS] [FILE]
./bin/mwc ./test.txt    # prints the line, word and byte count
./bin/mwc -c ./test.txt # prints the byte count
./bin/mwc -l ./test.txt # prints the line count
./bin/mwc -L ./test.txt # print the length of the longest line
./bin/mwc -m ./test.txt # prints the character count
./bin/mwc -w ./test.txt # prints the word count

# can also read input from stdin
cat ./test.txt | ./bin/mvc # equivalent to `./bin/mwc ./test.txt`

Todo

  • '-L' option (print the length of the longest line)
  • help option (maybe use flag or something for reading args)
  • that total count thing wc does when you give it multiple files

About

mediocre wc (the unix command) clone


Languages

Language:Go 100.0%