Skip to content

abrishk26/wc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Word Count Utility

This project is a command-line utility written in Go that counts the number of words or lines from standard input. This is similar to the wc command in Unix-like systems, providing functionality to count words by default and lines with an optional flag.

Features

  • Word Counting: Counts the total number of words by default.
  • Line Counting: With the -l flag, counts the total number of lines instead of words.

Installation

Ensure that Go (version 1.23.2 or later) is installed on your system.

  1. Clone this repository:

    git clone https://github.com/abrishk26/wc.git
    cd wc
  2. Build the project:

    go build -o wc

Usage

Run the compiled program and pipe in text via standard input. Use the -l flag to count lines instead of words.

Examples

  1. Counting Words:

    echo "Hello World" | ./wc
  2. Counting Lines:

    echo -e "Line 1\nLine 2" | ./wc -l

Code Structure

  • main.go: Contains the main functionality, including:
    • Parsing flags for word or line counting.
    • Counting words or lines using the count function, which scans input and increments a counter based on the mode specified.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages