Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/victoriacheng15/cc-wc-js
JS wc command reimagined: Conquer John Crickett's code challenge
https://github.com/victoriacheng15/cc-wc-js
javascript unix
Last synced: 26 days ago
JSON representation
JS wc command reimagined: Conquer John Crickett's code challenge
- Host: GitHub
- URL: https://github.com/victoriacheng15/cc-wc-js
- Owner: victoriacheng15
- License: mit
- Created: 2023-11-30T16:56:42.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-01-09T03:53:46.000Z (10 months ago)
- Last Synced: 2024-10-03T23:41:08.779Z (about 1 month ago)
- Topics: javascript, unix
- Language: JavaScript
- Homepage:
- Size: 193 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Coding Challenges - Write Your Own wc Tool
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 fileThis implementation provides a fun and practical way to explore JavaScript and its capabilities.
## Getting Started
1. Installation
```
git clone [email protected]:victoriacheng15/cc-write-your-wc-tool.gitcd cc-write-your-wc-tool
```2. Set up
```
npm link
```3. Run the command
```
ccwc -m example.txt
```Note: keep in mind, that the `ccwc` command only works in this directory.
## Usage
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 |### Basic Usage
There are two ways to use `ccwc`:
1. File as input:
```bash
ccwc [option] [file]
```example:
```bash
ccwc -l example.txt
```2. Standard Input
You can pip date directly to the tool using standard input:
```bash
cat example.txt | ccwc -flag
```exmaple:
```bash
cat example.txt | ccwc -l
```### Default Behavior
If you don't specify any flag, the tool will automatically print the byte, line, word counts
example:
```bash
ccwc example.txt# output:
7137 58159 341836 example.txt
```### Summary
- 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`, and `words` count.## Links
- [Write Your Own wc Tool](https://codingchallenges.fyi/challenges/challenge-wc)
- [Coding Challenges on Substack](https://codingchallenges.substack.com/)