Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/letsmakecakes/wc-tool
Unix command line tool wc built using Golang
https://github.com/letsmakecakes/wc-tool
go golang linux-shell
Last synced: 1 day ago
JSON representation
Unix command line tool wc built using Golang
- Host: GitHub
- URL: https://github.com/letsmakecakes/wc-tool
- Owner: letsmakecakes
- Created: 2024-01-14T17:08:21.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-02-24T15:06:39.000Z (9 months ago)
- Last Synced: 2024-02-24T16:26:13.410Z (9 months ago)
- Topics: go, golang, linux-shell
- Language: Go
- Homepage:
- Size: 135 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WC - Word Count Command in Golang
A simple implementation of the `wc` (word count) command in Golang. This project provides basic functionality to count lines, words, characters, and bytes in a file.
## Table of Contents
- [About the Project](#about-the-project)
- [Usage](#usage)
- [Options](#options)## About the Project
The `wc` command is a utility in Unix and Unix-like operating systems that provides line, word, and byte count options. This Golang implementation offers a subset of the `wc` functionality.
## Usage
To use this `wc` implementation, run the following command:
```bash
go run main.go -
```Replace `` with one of the following:
- `-c` : Byte count
- `-l` : Line count
- `-w` : Word count
- `-m` : Character count
- (No option) : Display line, word, byte countReplace `` with the path to the file you want to analyze.
Example:
```bash
go run main.go -l sample.txt
```## Options
- `-c` : Display the byte count.
- `-l` : Display the line count.
- `-w` : Display the word count.
- `-m` : Display the character count.
- (No option) : Display all counts (lines, words, bytes).### Sample Output Cases
Assuming your `main.go` is set up to handle command-line arguments and call the appropriate `wc` function:
#### Byte Count (`-c`)
```bash
go run main.go -c example.txt
# Output: 123 example.txt
```#### Line Count (`-l`)
```bash
go run main.go -l example.txt
# Output: 10 example.txt
```#### Word Count (`-w`)
```bash
go run main.go -w example.txt
# Output: 35 example.txt
```#### Character Count (`-m`)
```bash
go run main.go -m example.txt
# Output: 157 example.txt
```#### All Counts (No Option)
```bash
go run main.go example.txt
# Output: 10 35 123 example.txt
```