ccwc is a simple command-line tool written in TypeScript that mimics the behavior of the Unix wc command. It counts the number of lines, words, and characters in a given text input, either from files or through streams.
- Word Counting: Counts the number of words in the input.
- Line Counting: Counts the number of lines in the input.
- Character Counting: Counts the number of characters in the input.
Ensure that you have Node.js and npm installed on your machine.
- Clone this repository:
- Navigate to the project directory:
- Install dependencies:
- run default
- Make the script executable
git clone https://github.com/fianso98/wc-tool
cd ccwc
npm install
npm run start
npm i -g pkg
than go and modify package.json "executable" script to suits your device than run
npm run exectuable
-c outputs the number of bytes in a file
ccwc -c test.txt
output > 342190 test.txt
-l outputs the number of lines in a file.
ccwc -l test.txt
output > 7145 test.txt
-w outputs the number of words in a file.
ccwc -w test.txt
output > 58164 test.txt
-m outputs the number of characters in a file.
ccwc -m test.txt
output > 339292 test.txt
no options are provided, which is the equivalent to the -c, -l and -w options
ccwc test.txt
output > 7145 58164 342190 test.txt
support being able to read from standard input if no filename is specified
cat test.txt | ccwc -l
output > 7145
Feel free to open issues or submit pull requests if you have suggestions or improvements for ccwc. Your feedback is valuable!
If you want to adjust the executable command in the package.json file to suit your machine, you can change it like this:
Copy code
"executable": "tsc && pkg dist/main.js --targets node18-macos-x64 --output ccwc"
Modify the --targets flag according to your Node.js version and operating system. For instance, if you are using Node.js version 14 on Windows, you might use --targets node14-win-x64. Adjust the --output flag if you want to change the output executable name. Make sure to refer to the pkg documentation for more details on available options.