This project implements a custom version of the Unix wc tool in JavaScript: ccwc. Like the original wc, it allows you to:
- Count the number of bytes in a file
- Count the number of lines in a file
- Count the number of words in a file
- Count the number of characters in a file
This implementation provides a fun and practical way to explore JavaScript and its capabilities.
- Installation
git clone git@github.com:victoriacheng15/cc-write-your-wc-tool.git
cd cc-write-your-wc-tool
- Set up
npm link
- Run the command
ccwc -m example.txt
Note: keep in mind, that the ccwc
command only works in this directory.
This tool helps you analyze a file's size and content. You can use it to count the number of bytes, lines, words, and characters in a file.
Flag | Description |
---|---|
-c | print the byte count |
-l | print the lines count |
-w | print the words count |
-m | print the characters count |
There are two ways to use ccwc
:
- File as input:
ccwc [option] [file]
example:
ccwc -l example.txt
- Standard Input
You can pip date directly to the tool using standard input:
cat example.txt | ccwc -flag
exmaple:
cat example.txt | ccwc -l
If you don't specify any flag, the tool will automatically print the byte, line, word counts
example:
ccwc example.txt
# output:
7137 58159 341836 example.txt
- Use
flags
to specify which count you want to see. - Provide a
file path
as input. - Alternatively, pipe
data
directly using standard input. - By default, the tool shows
bytes
,lines
, andwords
count.